我有一个31个项目的列表,每个项目都有4个textViews。我将所有文本视图包装在线性布局中。我在代码中显示了1。就像那一个一样,我还有30个以上:
<LinearLayout
android:layout_width="match_parent"
android:layout_height="200dp"
android:orientation="horizontal">
<TextView
android:layout_width="0dp"
android:layout_height="match_parent"
android:text="loren"
android:textColor="#000"
android:gravity="center"
android:textSize="20dp"
android:layout_weight="10"/>
<TextView
android:layout_width="0dp"
android:layout_height="match_parent"
android:text="5"
android:textColor="#000"
android:gravity="center"
android:textSize="20dp"
android:layout_weight="2"/>
<TextView
android:layout_width="0dp"
android:layout_height="match_parent"
android:text="25"
android:textColor="#000"
android:gravity="center"
android:textSize="20dp"
android:layout_weight="2"/>
<TextView
android:layout_width="0dp"
android:layout_height="match_parent"
android:text="9"
android:textColor="#000"
android:gravity="center"
android:textSize="20dp"
android:layout_weight="2"/>
</LinearLayout>
为了清楚起见,只显示了一个结果代码。
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/fragment_globe"
android:background="@color/dashBackground">
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="200dp"
android:orientation="horizontal">
<TextView
android:layout_width="0dp"
android:layout_height="match_parent"
android:text="loren"
android:textColor="#000"
android:gravity="center"
android:textSize="20dp"
android:layout_weight="10"/>
<TextView
android:layout_width="0dp"
android:layout_height="match_parent"
android:text="5"
android:textColor="#000"
android:gravity="center"
android:textSize="20dp"
android:layout_weight="2"/>
<TextView
android:layout_width="0dp"
android:layout_height="match_parent"
android:text="25"
android:textColor="#000"
android:gravity="center"
android:textSize="20dp"
android:layout_weight="2"/>
<TextView
android:layout_width="0dp"
android:layout_height="match_parent"
android:text="9"
android:textColor="#000"
android:gravity="center"
android:textSize="20dp"
android:layout_weight="2"/>
</LinearLayout>
</LinearLayout>
</ScrollView>
</androidx.constraintlayout.widget.ConstraintLayout>
我无法滚动所有项目或所有线性布局。我可以滚动到某个点,但随后它停止向下滚动。我是Android新手,请帮助我。
在ScrollView中添加以下两个属性:android:layout_height =“ 0dp” app:layout_constraintBottom_toBottomOf =“ parent”