0

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:

enter image description here

But when I clicked the “Scroll” button, I executed the code linearLayout.scrollTo(0, 600); , and the layout became like this:

enter image description here

The height of the ListView is not filled with the remaining layout,How do I solve this problem ? Thanks !!!

Liu Silong
  • 4,902
  • 3
  • 19
  • 28

0 Answers0