Android:垂直拉伸按钮
问题描述:
我有一个应用程序中底部有两个按钮(在RelativeLayout内的TableLayout中)。这在小屏幕上看起来很好,但在较大的屏幕上底部留下了一个难看的黑色空间。我想垂直扩展按钮来填充空间,但不能解决问题!Android:垂直拉伸按钮
我已经包含下面的代码(与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>
任何人有任何想法如何拉伸当前布局中的按钮,还是不同的布局,可以让我更轻松地做到这一点?
感谢,
答
经过一些(很多)更多的实验后,结果证明我正在接近错误的方向。通过删除TableLayout,并用LinearLayout替换它,fill_parent属性的高度开始按预期工作,并且都很好。
答
作为一个相对布局内你能不使用属性android:layout_alignParentBottom='true'
并迫使按钮的底部边缘与布局的底部边缘对齐?您可以应用底部空白来留下一些空白。
感谢您的答复,但我设法遇到了LinearLayouts解决方案的解决方案。不管怎么说,还是要谢谢你! – Dan 2011-02-07 23:53:13