There is a GridLayout in which there are two TableLayout . I need these TableLayout 's to stretch according to the weights. But for some reason the first markup turns out to be too wide (although in the code above, the two markup should occupy the same space). Code:
<?xml version="1.0" encoding="utf-8"?> <android.support.v7.widget.GridLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" xmlns:grid="http://schemas.android.com/apk/res-auto" grid:columnCount="2" grid:rowCount="1"> <TableLayout grid:layout_row="0" grid:layout_column="0" grid:layout_columnWeight="1" android:stretchColumns="*" > <TableRow> <Button android:text="1" /> <Button android:text="2" /> </TableRow> </TableLayout> <TableLayout grid:layout_row="0" grid:layout_column="1" grid:layout_columnWeight="1" android:stretchColumns="*" > <TableRow> <Button android:text="3" /> <Button android:text="4" /> </TableRow> </TableLayout> </android.support.v7.widget.GridLayout> Result:
Why is this and how to fix it?
Addition
In the real code inside GridLayout can be several TableLayout and other views.

LinearLayoutand specify the horizontal orientation in it, set the weights forTableLayout1 and 1, respectively. - SilentoGridLayoutLinearLayout? This does not suit me very much, because in the real code inGridLayoutstill a lot of elements, the same table layouts. - Im ieee pmGridLayout- Silento