我正在尝试创建一个电话拨号器视图,使用 TableLayout 在 3x4 网格中创建 12 个按钮。我希望行垂直拉伸以平等地使用所有可用空间,但似乎 fill_parent 在 TableRows 上不起作用。
我不想使用 setMinimumHeight - 有没有办法在布局中正确执行此操作?
非常感谢,
Ed
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<TableLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:stretchColumns="*"
>
<TableRow
android:layout_weight="1"
android:gravity="center">
<Button android:text="Button" android:layout_width="fill_parent" android:layout_height="fill_parent"/>
<Button android:text="Button" android:layout_width="fill_parent" android:layout_height="fill_parent"/>
<Button android:text="Button" android:layout_width="fill_parent" android:layout_height="fill_parent"/>
</TableRow>
<TableRow
android:layout_weight="1"
android:gravity="center">
<Button android:text="Button" android:layout_width="fill_parent" android:layout_height="fill_parent"/>
<Button android:text="Button" android:layout_width="fill_parent" android:layout_height="fill_parent"/>
<Button android:text="Button" android:layout_width="fill_parent" android:layout_height="fill_parent"/>
</TableRow>
<TableRow
android:layout_weight="1"
android:gravity="center">
<Button android:text="Button" android:layout_width="fill_parent" android:layout_height="fill_parent"/>
<Button android:text="Button" android:layout_width="fill_parent" android:layout_height="fill_parent"/>
<Button android:text="Button" android:layout_width="fill_parent" android:layout_height="fill_parent"/>
</TableRow>
<TableRow
android:layout_weight="1"
android:gravity="center">
<Button android:text="Button" android:layout_width="fill_parent" android:layout_height="fill_parent"/>
<Button android:text="Button" android:layout_width="fill_parent" android:layout_height="fill_parent"/>
<Button android:text="Button" android:layout_width="fill_parent" android:layout_height="fill_parent"/>
</TableRow>
</TableLayout>
</LinearLayout>
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)