представление не может быть приостановлено на BottomNavigationView - PullRequest
0 голосов
/ 02 ноября 2018
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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:id="@+id/container"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".Main2Activity">
   <android.support.design.widget.BottomNavigationView
        android:id="@+id/navigation"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:background="?android:attr/windowBackground"
        app:menu="@menu/navigation" />
    <TextView
        android:id="@+id/message"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_above="@id/navigation"
        android:layout_centerInParent="true"
        android:gravity="center"
        android:text="@string/title_home" />
    <Button
        android:id="@+id/button"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignTop="@id/navigation"
        android:layout_alignBottom="@id/navigation"
        android:background="#ff0000" />
    </RelativeLayout>

Это простая раскладка. Я хочу, чтобы кнопка была приостановлена ​​в окне навигации снизу, но она не работает. Это мой код

введите описание изображения здесь

1 Ответ

0 голосов
/ 02 ноября 2018

Если вы хотите, чтобы кнопка находилась перед BottomNavigationView, вы должны объявить расположение кнопок следующим образом:

<Button
        android:id="@+id/button"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignTop="@+id/navigation"
        android:layout_alignBottom="@+id/navigation"
        android:background="#ff0000" />

Если вы хотите, чтобы он всегда был выше вашего BottomNavigationView:

<Button
        android:id="@+id/button"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_above="@+id/navigation"
        android:background="#ff0000" />
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...