I have 3 columns of buttons, but the columns don't all contain the same quantity of buttons. What is the best practice for making all of the buttons appear the same size? I don't want to explicitly specify the button widths and I doubt that adding "dummy" buttons is best either.
<TableLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:stretchColumns="*"
<TableRow
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<Button
android:layout_width="0dip"
android:layout_weight="1"
android:text="Button 1"
android:id="@+id/button1" />
<Button
android:layout_width="0dip"
android:text="Button 2"
android:id="@+id/button2"
android:layout_weight="1" />
<Button
android:layout_width="0dip"
android:text="Button 3"
android:id="@+id/button3"
android:layout_weight="1"/>
</TableRow>
<TableRow
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<Button
android:layout_width="0dp"
android:layout_weight="1"
android:text="Button 4"
android:id="@+id/button4" />
<Button
android:layout_width="0dp"
android:layout_weight="1"
android:text="Button 5"
android:id="@+id/button5"
android:layout_column="3" />
</TableRow>
</TableLayout>
This is more like a math problem. For centering odds (3) and even (2) in an expandable grid space, you'll need in total a six celled layout.
Here's the solution (without any extra views and not using layout weights):