Выкладываю выровненные снизу кнопки - PullRequest
2 голосов
/ 03 марта 2012

Есть ли лучший способ сделать это, чтобы кнопки были выровнены снизу с обеих сторон экрана? Важными частями являются alignParentBottom, который, по-видимому, доступен только в RelativeLayout, и layout_gravity, который, по-видимому, доступен только в LinearLayout и его подклассах, таких как TableLayout, из которых RelativeLayout не один.

<RelativeLayout
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true">
        <TableLayout
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:stretchColumns="1">
            <TableRow>
                <Button
                    android:id="@+id/list_delete"
                    android:text="@string/list_delete"
                    android:visibility="invisible"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    />
                <Button
                    android:id="@+id/list_save"
                    android:text="@string/list_add"
                    android:layout_gravity="right"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    />
            </TableRow>
        </TableLayout>
    </RelativeLayout>

Android lint дает мне такие ошибки:

  • Этот макет TableLayout или его родительский объект RelativeLayout бесполезен
  • Этот макет TableRow или его родительский объект TableLayout бесполезен

1 Ответ

4 голосов
/ 03 марта 2012

Попробуйте это

   <RelativeLayout//this will be your parent layout
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    >


            <Button
                android:id="@+id/list_delete"
                android:text="@string/list_delete"
                android:visibility="invisible"
                android:layout_alignParentBottom="true"
                android:layout_alignParentLeft="true"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                />
            <Button
                android:id="@+id/list_save"
                android:text="@string/list_add"
                android:layout_alignParentBottom="true"
                android:layout_alignParentRight="true"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                />


</RelativeLayout>
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...