Android TableLayout - equal width and equal cell height - doesn't work, why

I have a 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 since I want to fill the screen).

I was sure that I was doing everything right, but, unfortunately, only the same width. The problem is that the height - the first two lines have the same height, the third - less (or, more precisely, as long as the buttons do not contain text, the height is the same, but when I put the text, the height is not equal). I could not believe that it did not work, so I even took screenshots, and I checked the distance in the graphics 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 also tried to set the height TableRowas match_parent. It does not help.

btw, shrinkColums , stretchColumns? ( shrinkColumns, , , .

+3
2

, . , . , :

setText("<html>your text<html>");

, , ,

0

tableLayout

<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">

   <TableRow 
        android:layout_width="match_parent"
        android:layout_height="0dip"
        android:layout_weight="1"
        android:gravity="center">
0

All Articles