列在Android的表格布局设置宽度相等 [英] Set equal width of columns in table layout in Android
问题描述
可能重复:
<一href="http://stackoverflow.com/questions/2865497/xml-table-layout-two-equal-width-rows-filled-with-equally-width-buttons">XML表格布局?两个等宽行充满了同样的宽度按钮?
我使用 TableLayout
来显示4列数据的列表。
I am using TableLayout
to show list of data in 4 columns.
问题描述:的
Problem description:
我无法将所有4列,这是在我的 TableLayout
的宽度相等。
我把我的布局code,我现在用的...
I am unable to set equal width of all 4 columns, which are in my TableLayout
.
I am putting my layout code, which I am using...
<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柱大小相等?的
推荐答案
使用这种方式: <一href="http://androidadvice.blogspot.com/2010/10/tablelayout-columns-equal-width.html">http://androidadvice.blogspot.com/2010/10/tablelayout-columns-equal-width.html
它归结为加入安卓stretchColumns =1
您 TableLayout
根和设置机器人:layout_width =0dp
在所有孩子的的TableRow的
It boils down to adding android:stretchColumns="1"
to your TableLayout
root and setting android:layout_width="0dp"
to all the children in your TableRow's
这篇关于列在Android的表格布局设置宽度相等的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!