XML Table layout? Two EQUAL-width rows filled with equally width buttons?

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

    <LinearLayout android:orientation="horizontal" 
         android:layout_width="fill_parent"
         android:layout_height="fill_parent">
         <Button android:layout_weight="1" 
             android:layout_height="wrap_content" 
             android:layout_width="0dip"/>
         <Button android:layout_weight="1" 
             android:layout_height="wrap_content" 
             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. These properties tell the layout that your views should take up equal space in the parent layout.

Leave a Comment