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:

too wide

Why is this and how to fix it?

Addition

In the real code inside GridLayout can be several TableLayout and other views.

  • Try to wrap all this in LinearLayout and specify the horizontal orientation in it, set the weights for TableLayout 1 and 1, respectively. - Silento
  • @Asgard in the sense of instead of GridLayout LinearLayout ? This does not suit me very much, because in the real code in GridLayout still a lot of elements, the same table layouts. - Im ieee pm
  • This is an illusion :) - Flippy
  • @Imieee not, to wrap is to make a parent for GridLayout - Silento

0