gpt4 book ai didi

android - 行分隔符在 ScrollView Android 中不起作用

转载 作者:行者123 更新时间:2023-11-29 01:14:04 25 4
gpt4 key购买 nike

当 ScrollView 作为根标签包含时,将屏幕一分为二的行分隔符不会显示。否则它工作正常。

这是我的布局文件。

 <ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">

<LinearLayout
android:id="@+id/firstLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_toLeftOf="@+id/secondView"
android:orientation="vertical"
android:paddingLeft="8dp">

<TextView
android:id="@+id/Goals"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="20dp"
android:layout_marginTop="15dp"
android:fontFamily="sans-serif-smallcaps"
android:text="Goals Scored- MANU"
android:textSize="18sp" />

<Button
android:id="@+id/AddButton1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingTop="20dp"
android:text="+" />

<Button
android:id="@+id/SubButton1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="20dp"
android:text="-" />


<TextView
android:id="@+id/Fouls"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="20dp"
android:fontFamily="sans-serif-smallcaps"
android:text="Fouls"
android:textSize="18sp" />

<Button
android:id="@+id/AddButton2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingTop="20dp"
android:text="+" />

<Button
android:id="@+id/SubButton2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="-" />


<TextView
android:id="@+id/goalsscoredteamone"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:textStyle="bold" />

<TextView
android:id="@+id/foulsmadeteamone"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:textStyle="bold" />

</LinearLayout>

<View
android:id="@+id/secondView"
android:layout_width="1dp"
android:layout_height="match_parent"
android:layout_centerHorizontal="true"
android:background="#000000" />

<LinearLayout
android:id="@+id/thirdLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_toRightOf="@+id/secondView"
android:orientation="vertical"
android:paddingLeft="8dp">

<TextView
android:id="@+id/Goalsteam2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="20dp"
android:layout_marginTop="15dp"
android:fontFamily="sans-serif-smallcaps"
android:text="Goals Scored MANC"
android:textSize="18sp" />

<Button
android:id="@+id/AddButton3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingTop="20dp"
android:text="+" />

<Button
android:id="@+id/SubButton3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="20dp"
android:text="-" />

<TextView
android:id="@+id/Foulsteam2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="20dp"
android:fontFamily="sans-serif-smallcaps"
android:text="Fouls"
android:textSize="18sp" />

<Button
android:id="@+id/AddButton4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingTop="20dp"
android:text="+" />
<Button
android:id="@+id/SubButton4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="-" />
<TextView
android:id="@+id/goalsscoredteamtwo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:textStyle="bold" />
<TextView
android:id="@+id/foulsmadeteamtwo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:textStyle="bold" />
</LinearLayout>
</RelativeLayout>

是否有任何必要的工作或任何可能的解决方案?

最佳答案

答案在这里将 android:fillViewport="true" 添加到您的 ScrollView 中,它将起作用!

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<ScrollView
android:fillViewport="true"
android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true">
<LinearLayout
android:id="@+id/firstLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_toLeftOf="@+id/secondView"
android:orientation="vertical"
android:paddingLeft="8dp">

<TextView
android:id="@+id/Goals"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="20dp"
android:layout_marginTop="15dp"
android:fontFamily="sans-serif-smallcaps"
android:text="Goals Scored- MANU"
android:textSize="18sp" />

<Button
android:id="@+id/AddButton1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingTop="20dp"
android:text="+" />

<Button
android:id="@+id/SubButton1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="20dp"
android:text="-" />


<TextView
android:id="@+id/Fouls"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="20dp"
android:fontFamily="sans-serif-smallcaps"
android:text="Fouls"
android:textSize="18sp" />

<Button
android:id="@+id/AddButton2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingTop="20dp"
android:text="+" />

<Button
android:id="@+id/SubButton2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="-" />


<TextView
android:id="@+id/goalsscoredteamone"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:textStyle="bold" />

<TextView
android:id="@+id/foulsmadeteamone"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:textStyle="bold" />

</LinearLayout>

<View
android:id="@+id/secondView"
android:layout_width="1dp"
android:layout_height="match_parent"
android:layout_centerHorizontal="true"
android:background="#000000" />

<LinearLayout
android:id="@+id/thirdLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_toRightOf="@+id/secondView"
android:orientation="vertical"
android:paddingLeft="8dp">

<TextView
android:id="@+id/Goalsteam2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="20dp"
android:layout_marginTop="15dp"
android:fontFamily="sans-serif-smallcaps"
android:text="Goals Scored MANC"
android:textSize="18sp" />

<Button
android:id="@+id/AddButton3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingTop="20dp"
android:text="+" />

<Button
android:id="@+id/SubButton3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="20dp"
android:text="-" />

<TextView
android:id="@+id/Foulsteam2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="20dp"
android:fontFamily="sans-serif-smallcaps"
android:text="Fouls"
android:textSize="18sp" />

<Button
android:id="@+id/AddButton4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingTop="20dp"
android:text="+" />
<Button
android:id="@+id/SubButton4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="-" />
<TextView
android:id="@+id/goalsscoredteamtwo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:textStyle="bold" />
<TextView
android:id="@+id/foulsmadeteamtwo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:textStyle="bold" />
</LinearLayout>
</RelativeLayout>


</ScrollView>



</RelativeLayout>

关于android - 行分隔符在 ScrollView Android 中不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40957876/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com