I have a TableLayout and a matrix of 8 by 8 small buttons described via XML . When you rotate the screen, some buttons are not visible.
How can you describe that for all kinds of screens the state is preserved and all elements are visible?

 <?xml version="1.0" encoding="UTF-8"?> <TableLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/Table8" android:layout_width="fill_parent" android:layout_height="fill_parent" android:padding="20dp" > <TableRow android:id="@+id/tableRow1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginTop="-4dp" android:layout_marginBottom="-4dp" > <Button android:id="@+id/button1" style="?android:attr/buttonStyleSmall" android:layout_width="35dp" android:layout_height="35dp" android:layout_marginRight="-4dp" android:layout_marginLeft="-4dp" android:text="" /> <Button android:id="@+id/button2" style="?android:attr/buttonStyleSmall" android:layout_width="35dp" android:layout_height="35dp" android:layout_marginRight="-4dp" android:layout_marginLeft="-4dp" android:text="" /> <Button android:id="@+id/button3" style="?android:attr/buttonStyleSmall" android:layout_width="35dp" android:layout_height="35dp" android:layout_marginRight="-4dp" android:layout_marginLeft="-4dp" android:text="" /> <Button android:id="@+id/button4" style="?android:attr/buttonStyleSmall" android:layout_width="35dp" android:layout_height="35dp" android:layout_marginRight="-4dp" android:layout_marginLeft="-4dp" android:text="" /> <Button android:id="@+id/button5" style="?android:attr/buttonStyleSmall" android:layout_width="35dp" android:layout_height="35dp" android:layout_marginRight="-4dp" android:layout_marginLeft="-4dp" android:text="" /> <Button android:id="@+id/button6" style="?android:attr/buttonStyleSmall" android:layout_width="35dp" android:layout_height="35dp" android:layout_marginRight="-4dp" android:layout_marginLeft="-4dp" android:text="" /> <Button android:id="@+id/button7" style="?android:attr/buttonStyleSmall" android:layout_width="35dp" android:layout_height="35dp" android:layout_marginRight="-4dp" android:layout_marginLeft="-4dp" android:text="" /> <Button android:id="@+id/button8" style="?android:attr/buttonStyleSmall" android:layout_width="35dp" android:layout_height="35dp" android:layout_marginRight="-4dp" android:layout_marginLeft="-4dp" android:text="" /> </TableRow> 

Here is one of the lines.

  • [Auto-transfer items to the next line in Android] [1] [1]: / questions / 79322 /% D0% B0% D0% B2% D1% 82% D0% BE% D0% BF% D0% B5% D1% 80% D0% B5% D0% BD% D0% BE% D1% 81-% D1% 8D% D0% BB% D0% B5% D0% BC% D0% B5% D0% BD% D1% 82% D0% BE% D0 % B2-% D0% BD% D0% B0-% D1% 81% D0% BB% D0% B5% D0% B4% D1% 83% D1% 8E% D1% 89% D1% 83% D1% 8E-% D1% 81% D1% 82% D1% 80% D0% BE% D0% BA% D1% 83-% D0% B2-android - sercxjo

1 answer 1

If the layout is designed correctly, then the screen rotation should not affect the visibility of individual elements.

The reason is most likely either in the fact that for the sizes of the elements either absolute dimensions are used, or android:layout_weight weights are not specified, or the elements are not packed in the ScrollView

  • If it is not difficult, describe exactly how to add and where to add android:layout_weight , now add hml code. - ramin