gpt4 book ai didi

android - 在Android中的表格布局中设置等宽的列

转载 作者:IT老高 更新时间:2023-10-28 13:14:55 29 4
gpt4 key购买 nike

Possible Duplicate:
XML Table layout? Two EQUAL-width rows filled with equally width buttons?

我正在使用 TableLayout 来显示 4 列中的数据列表。

问题描述:

我无法将我的 TableLayout 中的所有 4 列设置为相等的宽度。我正在输入我正在使用的布局代码...

<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 列大小相等?

最佳答案

Try this.

归结为将 android:stretchColumns="*" 添加到您的 TableLayout 根并将 android:layout_width="0dp" 设置为TableRows 中的所有 child 。

<TableLayout
android:stretchColumns="*" // Optionally use numbered list "0,1,2,3,..."
>
<TableRow
android:layout_width="0dp"
>

关于android - 在Android中的表格布局中设置等宽的列,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6647177/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com