I have a layout defined as the following.
<ScrollView
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="10dp">
<LinearLayout
android:id="@+id/section1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="20dp"
android:text="@string/anomaly_products_title"
android:textColor="@color/title"
android:textSize="16sp"
android:textStyle="bold" />
<ListView
android:id="@+id/section1_list"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="40dp"
android:divider="@android:color/transparent"
android:dividerHeight="20dp" />
</LinearLayout>
.... Some Other section
</LinearLayout>
</ScrollView>
I also defined the item of the list as follows.
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="13dp"
android:background="@drawable/semi_rounded">
<CheckBox
android:id="@+id/checkbox_item"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="16sp" />
</LinearLayout>
I would like to set the height of the ListView
to the height of all his elements and make it non-scrollable. The scroll must only occur on the parent ScrollView
. For that, I have found the function setListViewHeightBasedOnChildren
here.
The problem is that my checkbox label can be displayed on multiple lines and thus increase the size of the item slightly. With many checkboxes in this situation, the ListView
becomes scrollable.
Is There any way to handle that case?