首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >在Android中设置表格布局的列宽相等

在Android中设置表格布局的列宽相等
EN

Stack Overflow用户
提问于 2011-07-11 15:49:52
回答 2查看 135.3K关注 0票数 78

可能重复:

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

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

问题描述:

我无法设置所有4列的宽度相等,这些列在我的TableLayout中。我把我的布局代码,我正在使用...

代码语言:javascript
复制
<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列?

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2011-07-11 15:55:04

Try this.

归根结底就是将android:stretchColumns="*"添加到TableLayout根目录,并将android:layout_width="0dp"设置为TableRow中的所有子目录。

代码语言:javascript
复制
<TableLayout
    android:stretchColumns="*"   // Optionally use numbered list "0,1,2,3,..."
>
    <TableRow
        android:layout_width="0dp"
    >
票数 209
EN

Stack Overflow用户

发布于 2011-07-11 16:01:20

android:stretchColumns值更改为*

0表示拉伸第一列。值1表示拉伸第二列,依此类推。

*表示拉伸所有列。

票数 73
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/6647177

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档