可能重复:
XML Table layout? Two EQUAL-width rows filled with equally width buttons?
我使用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列?
发布于 2011-07-11 15:55:04
归根结底就是将android:stretchColumns="*"
添加到TableLayout
根目录,并将android:layout_width="0dp"
设置为TableRow
中的所有子目录。
<TableLayout
android:stretchColumns="*" // Optionally use numbered list "0,1,2,3,..."
>
<TableRow
android:layout_width="0dp"
>
发布于 2011-07-11 16:01:20
将android:stretchColumns
值更改为*
。
值0
表示拉伸第一列。值1
表示拉伸第二列,依此类推。
值*
表示拉伸所有列。
https://stackoverflow.com/questions/6647177
复制相似问题