I have TableLayout and I would like to have buttons as cells. All buttons should have the same width. And all buttons should have the same height. (Weight and height will be different as I want to fill the screen).
I was sure that I'm doing everything right but unfortunately only the width is the same. The problem is with height - first two rows have the same height, the third is smaller (or more precisely as long as buttons doesn't contain any text, the height is the same, but when I put text, the height is not equal). I couldn't believe that it doesn't work so I made even screenshoot and I checked the distance in graphical program.
My table:
<TableLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="0dip"
android:layout_weight="1"
android:stretchColumns="*"
android:shrinkColumns="*"
android:weightSum="3"
android:padding="@dimen/dialog_margin"
>
<TableRow
android:layout_width="match_parent"
android:layout_height="0dip"
android:layout_weight="1"
android:stretchColumns="*"
android:gravity="center"
android:weightSum="2">
<Button
android:id="@+id/button_0"
android:layout_width="0dip"
android:layout_height="match_parent"
android:layout_weight="1"
/>
<Button
android:id="@+id/button_1"
android:layout_width="0dip"
android:layout_height="match_parent"
android:layout_weight="1"
/>
</TableRow>
<TableRow
android:layout_width="match_parent"
android:layout_height="0dip"
android:layout_weight="1"
android:stretchColumns="*"
android:gravity="center"
android:weightSum="2">
// buttons analogously as in previous row....
</TableRow>
<TableRow
android:layout_width="match_parent"
android:layout_height="0dip"
android:layout_weight="1"
android:stretchColumns="*"
android:gravity="center"
android:weightSum="2">
// buttons analogously as in previous row....
</TableRow>
I tried also to set the TableRow
height as match_parent
. It doesn't help.
And btw how shrinkColums
work, in particular together with stretchColumns
? (I had version with and without shrinkColumns
and it seems there is no difference.