I have a question about the height of the ListView.the layout is as follows:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/linear_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<View
android:layout_width="match_parent"
android:layout_height="300dp"
android:background="@color/colorAccent" />
<Button
android:layout_width="match_parent"
android:layout_height="20dp"
android:background="@color/colorPrimary"
android:onClick="scroll"
android:text="Scroll" />
<ListView
android:id="@+id/list_view"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>
The initial state of the page:
But when I clicked the “Scroll” button, I executed the code linearLayout.scrollTo(0, 600);
, and the layout became like this:
The height of the ListView is not filled with the remaining layout,How do I solve this problem ? Thanks !!!