Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Spanning columns with TableLayout [duplicate]

Possible Duplicate:
What is the equivalent of “colspan” in an Android TableLayout?

It says in the documentation for TableLayout "Cells can span columns, as they can in HTML." However, I can't find any way to do so.

Specifically, I have one row with two columns and another with one column. I want the one column row to span the entire table. Seems easy, but I don't see it.

like image 585
Shawn Lauzon Avatar asked Aug 27 '11 05:08

Shawn Lauzon


2 Answers

add android:layout_span="3" to span 3 columns. For example:

        <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>
like image 125
IncrediApp Avatar answered Oct 21 '22 06:10

IncrediApp


android:layout_span does the trick.

example:

<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>
like image 3
segfaultomatic Avatar answered Oct 21 '22 06:10

segfaultomatic