TiagoM TiagoM - 19 days ago 7
Android Question

Table Fill can't fill Row with Buttons

I am trying to fill the first row of my table with only one button.. and the second row divided with two buttons, but I can't do it..
It appears always like this:



I already add the lines:
android:stretchColumns=""
android:shrinkColumns="
"

Any clue why? This is how my XML is at the moment:

<?xml version="1.0" encoding="utf-8"?>
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/tableLayout1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:stretchColumns="*"
android:shrinkColumns="*" >

<!-- 1 column -->
<TableRow
android:id="@+id/tableRow1"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >

<Button
android:id="@+id/button1"
android:text="Column 2" />
</TableRow>

<!-- 2 columns -->
<TableRow
android:id="@+id/tableRow2"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >

<Button
android:id="@+id/button2"
android:text="Column 3" />

<Button
android:id="@+id/button3"
android:text="Column 4" />
</TableRow>





</TableLayout>

Answer

Add android:layout_span="2" to your first Button:

<Button
     android:id="@+id/button1"
     android:layout_span="2"    
     android:text="Column 2" />
Comments