Две строки взвешенных кнопок - PullRequest
0 голосов
/ 24 января 2019

Я пытаюсь отобразить экран главного меню с четырьмя кнопками, двумя рядами из двух кнопок, которые взвешены в нижней части страницы.Единственная проблема в том, что верхний ряд кнопок закрывает нижний ряд.Любая помощь с благодарностью!

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_margin="4dp"
    android:orientation="horizontal"
    android:layout_gravity="bottom"
    tools:context="MainActivity">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:id="@+id/relativeLayout"
        android:orientation="horizontal">

        <Button
            android:id="@+id/btn1"
            android:layout_width="0dp"
            android:layout_weight="1"
            android:layout_height="wrap_content"
            android:text="@string/btn_1" />

        <Button
            android:id="@+id/btn2"
            android:layout_width="0dp"
            android:layout_weight="1"
            android:layout_height="wrap_content"
            android:text="@string/btn_2" />

    </LinearLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal">

        <Button
            android:id="@+id/btn3"
            android:layout_width="0dp"
            android:layout_weight="1"
            android:layout_height="wrap_content"
            android:text="@string/btn_3" />

        <Button
            android:id="@+id/btn4"
            android:layout_width="0dp"
            android:layout_weight="1"
            android:layout_height="wrap_content"
            android:text="@string/btn_4" />

    </LinearLayout>

</LinearLayout>

1 Ответ

0 голосов
/ 24 января 2019

Я думаю, что единственное, что вам нужно сделать, это установить ориентацию корневого LinearLayout на «вертикальный».

Ориентация корневого LinearLayout является «горизонтальным», а ширина двух LinearLayout, которыеВ корне LinearLayout содержатся «match_parent», поэтому верхний ряд кнопок всегда будет покрывать нижний ряд.

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