Android 如何动态更改ListView的高度

Android 如何动态更改ListView的高度,android,listview,android-custom-view,Android,Listview,Android Custom View,我有一个关于ListView高度的问题。布局如下: <?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="

我有一个关于ListView高度的问题。布局如下:

<?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>

页面的初始状态:

但是当我点击“滚动”按钮时,我执行了代码
linearLayout.scrollTo(0600),布局如下:


ListView的高度没有填充剩余的布局,如何解决此问题?谢谢!!!

如果您希望元素能够相互重叠,请使用框架布局。您希望实现什么?请查找此选项可能会有所帮助you@SurajVaishnav我想实现一个像instagram一样的照片采集器。上半部分是选定的图像,下半部分是使用GridView布局显示的相册,整个布局可以上下滑动。