43

重複の可能性:
Android TableLayout の「colspan」に相当するものは何ですか?

TableLayout のドキュメントには、「HTML と同様に、セルは複数の列にまたがることができます」と書かれています。しかし、私はそうする方法を見つけることができません。

具体的には、2 つの列を持つ 1 つの行と 1 つの列を持つ別の行があります。1 列の行がテーブル全体にまたがるようにします。簡単に見えますが、わかりません。

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 に答える