0

我有一个应用程序,其中底部并排有两个按钮(在RelativeLayout 内的TableLayout 中)。这在小屏幕上看起来不错,但在大屏幕上,底部会留下难看的黑色空间。我想垂直扩展按钮以填充空间,但不知道如何!

我已经包含了下面的代码(为简单起见,删除了 RelativeLayout 的内容;下面的行为与它的版本完全相同)

<RelativeLayout android:id="@+id/RelativeLayout01" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    xmlns:android="http://schemas.android.com/apk/res/android">

    <TableLayout android:id="@+id/TableLayout01" android:layout_width="fill_parent" android:layout_height="fill_parent">
        <TableRow android:layout_width="fill_parent" android:layout_height="fill_parent">
            <Button android:layout_width="wrap_content" android:id="@+id/Button01" android:text="@string/Button01" android:layout_weight="50" android:layout_height="fill_parent"></Button>
            <Button android:layout_width="wrap_content" android:id="@+id/Button02" android:text="@string/Button02" android:layout_weight="50" android:layout_height="fill_parent"></Button>
        </TableRow>
    </TableLayout>

</RelativeLayout>

任何人都知道如何在当前布局中拉伸按钮,或者让我更容易做到这一点的不同布局?

谢谢,

4

2 回答 2

0

由于您在相对布局中,您可以不使用该属性android:layout_alignParentBottom='true'并强制按钮的底部边缘与布局的底部边缘对齐吗?您可以应用底部边距以留下一些空白。

于 2011-02-07T20:25:11.157 回答
0

经过一点(很多)实验后,事实证明我以错误的方式接近这个。通过删除 TableLayout 并用 LinearLayout 替换它,高度的 fill_parent 属性开始按预期工作,一切都很好。

于 2011-02-07T23:52:32.547 回答