可能的重复:
XML 表布局?两个等宽的行充满了等宽的按钮?
我在用TableLayout
以 4 列显示数据列表。
问题描述:
我无法将我的所有 4 列设置为相等宽度TableLayout
。
我正在放置我正在使用的布局代码......
<TableLayout android:layout_width="fill_parent" android:layout_height="wrap_content" android:stretchColumns="0">
<TableRow>
<TextView android:text="table header1" android:layout_width="wrap_content" android:layout_height="wrap_content"
android:textSize="10dip" android:textStyle="bold"/>
<TextView android:text="table header2" android:layout_width="wrap_content" android:layout_height="wrap_content"
android:textSize="10dip" android:textStyle="bold"/>
<TextView android:text="table header3" android:layout_width="wrap_content" android:layout_height="wrap_content"
android:textSize="10dip" android:textStyle="bold"/>
<TextView android:text="table header4" android:layout_width="wrap_content" android:layout_height="wrap_content"
android:textSize="10dip" android:textStyle="bold"/>
</TableRow>
</TableLayout>
我应该如何重写此布局以显示大小相等的 4 列?
尝试这个。
归结为添加android:stretchColumns="*"
给你的TableLayout
根和设置android:layout_width="0dp"
给你家中的所有孩子TableRow
s.
<TableLayout
android:stretchColumns="*" // Optionally use numbered list "0,1,2,3,..."
>
<TableRow
android:layout_width="0dp"
>
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)