43

可能重复:
Android TableLayout 中的“colspan”等价物是什么?

它在 TableLayout 的文档中说“单元格可以跨列,就像它们在 HTML 中一样。” 但是,我找不到任何方法。

具体来说,我有一排两列,另一排一列。我希望一列行跨越整个表格。似乎很容易,但我没有看到它。

4

2 回答 2

75

添加 android:layout_span="3" 以跨越 3 列。例如:

        <TableRow>
            <Button android:id="@+id/item_id"
                android:layout_span="2"
                android:layout_width="wrap_content" 
                android:layout_height="wrap_content" 
                android:text="item text" />     
        </TableRow>
于 2011-08-27T06:08:01.260 回答
3

android:layout_span 可以解决问题。

例子:

<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TableRow>
    <TextView android:id="@+id/info"
        android:layout_span="2"
        android:text="some text"
        android:padding="3dip"
        android:layout_gravity="center_horizontal" />
</TableRow>
<TableRow>
    <TextView android:text="some other text" 
        android:padding="3dip" />
    <TextView android:text="more text" 
        android:padding="3dip" />
</TableRow>
</TableLayout>
于 2011-08-27T06:27:24.093 回答