1

У меня есть TableLayout и матрица смолл кнопок 8 на 8 описанных через XML. При повороте экрана часть кнопок не видно.
Как можно описать, чтобы для любых видов экранов состояние сохранялось и все элементы видны были?

<?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>

Вот одна из строк.

1
  • [Автоперенос элементов на следующую строку в 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
    21 июн 2012 в 6:53

1 ответ 1

1

Если лэйаут спроектирован правильно, то поворот экрана не должен сказываться на видимости отдельных элементов.

Причина скорее всего либо в том, что для размеров элементов используются либо абсолютные размеры, либо не задаются веса android:layout_weight, либо элементы не пакуются в ScrollView

1
  • Если не трудно, распишите как именно добавить и куда добавить android:layout_weight, сейчас добавлю хмл код.
    – ramin
    21 июн 2012 в 7:11

Ваш ответ

Нажимая на кнопку «Отправить ответ», вы соглашаетесь с нашими условиями использования и подтверждаете, что прочитали и поняли наши политику конфиденциальности и нормы поведения.

Всё ещё ищете ответ? Посмотрите другие вопросы с метками или задайте свой вопрос.