Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/extjs/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 在与父对象对齐时填充可用空间_Android_Android Relativelayout - Fatal编程技术网

Android 在与父对象对齐时填充可用空间

Android 在与父对象对齐时填充可用空间,android,android-relativelayout,Android,Android Relativelayout,LinearLayout粘贴到RelativeLayout的底部,但具有固定的高度(其子项的包裹内容-按钮) 我希望LinearLayout有尽可能多的可用空间(因为ListView可以有0或1000个元素),但也要确保当ListView有很多元素时按钮仍然可见 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/

LinearLayout粘贴到RelativeLayout的底部,但具有固定的高度(其子项的包裹内容-按钮)

我希望LinearLayout有尽可能多的可用空间(因为ListView可以有0或1000个元素),但也要确保当ListView有很多元素时按钮仍然可见

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent" >

<ListView
    android:id="@+id/listView1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_above="@+id/linear"
    android:layout_alignParentTop="true">
</ListView>


<LinearLayout
    android:id="@+id/linear"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"
    android:orientation="vertical" >

    <Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Button" >
    </Button>
</LinearLayout>


尝试以下方法,看看是否有效:

  • 将RelativeLayout更改为LinearLayout,并添加android:orientation=“vertical”
  • 为“listview1”和“linear”指定不同的布局权重。对于listview1,使用android:layout_weight=“1”。对于“线性”,请使用android:layout\u weight=“2”

  • 希望有帮助。

    再多解释一点。你的布局有什么问题?当前的行为不好?或在此添加屏幕截图。线性布局的高度限制为按钮的高度。我希望这个线性布局有尽可能多的高度,而不仅仅是按钮所需的数量。那么listview的高度呢?