views:

743

answers:

1

Hi heres a part from my XML for LAND format:

<TableLayout
    android:layout_height="wrap_content"
    android:layout_width="wrap_content"
    android:layout_gravity="center"
    android:stretchColumns="*">
<TableRow>    
    <Button
        android:id="@+id/countbutton"
        android:text="@string/plus1"/>      
    <Button
        android:id="@+id/resetbutton"
        android:text="@string/reset" 
        />  
</TableRow>
</TableLayout>

And now what I dont get - the WIDTH of one row and also of the button depends on the TEXT inside the button. If the both texts are equaly long lets say : TEXT its ok - the table half is in the middle of the screen. But if they have different size - lets say "A" and "THIS IS THE LONG BUTTON" the CENTER of the table isnt in the middle of the screen anymore and so the buttons are not equally width...

Cant find any solution...

Please advise...

Thank you

Oliver Goossens

+7  A: 

To have buttons in rows where buttons are the same size you need to do.

<LinearLayout android:orientation="horizontal">
     <Button android:layout_weight="1" android:layout_width="0dip"/>
     <Button android:layout_weight="1" android:layout_width="0dip"/>
</LinearLayout>

And fill in the other xml properties for your buttons.

The magic is in the layout_weight and width properties. YOu don't need the Table layout.

BrennaSoft