Я создаю приложение, и когда я загружаю представление с помощью BottomNavigationView
, у меня постоянно возникают странные проблемы, иногда у меня появляется лишний пробел, а в других случаях панель инструментов расположена неправильно, например:
С нижней навигацией:
![bottomnavigation](https://i.stack.imgur.com/Gew6H.jpg)
Без нижней навигации:
![no bottom navigation](https://i.stack.imgur.com/3WnIl.jpg)
Это мой код для 1-го изображения:
<?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"
android:background="@android:color/white"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<include
layout="@menu/toolbar_recipe" />
<FrameLayout
android:id="@+id/content_frame"
android:layout_height="0dp"
android:layout_weight="1"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
android:layout_width="match_parent" />
<android.support.design.widget.BottomNavigationView
android:id="@+id/bottom_navigation"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
app:menu="@menu/bottom_nav_menu"
app:labelVisibilityMode="unlabeled"
app:itemBackground="@color/colorPrimary"
app:itemIconTint="@color/bottom_nav_color"
app:itemTextColor="@color/bottom_nav_color" />
</LinearLayout>
</RelativeLayout>
Панель инструментов:
<?xml version="1.0" encoding="UTF-8" ?>
<android.support.v7.widget.Toolbar
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/toolbar_recipe"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:theme="@style/ToolBarStyle"
android:minHeight="?android:attr/actionBarSize"
android:background="@color/colorPrimary"/>
И вот как он ведет себя с CoordinatorLayout
, после того, как я установил paddingTop как ?attr/actionBarSize
, FrameLayout
переместил некоторое пространство, но оно все равно неправильно расположено.
![odd space](https://i.stack.imgur.com/ZDrHH.png)
С CoordinatorLayout:
<?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"
android:background="@android:color/white"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.design.widget.CoordinatorLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
android:layout_above="@+id/bottom_navigation">
<include
layout="@menu/toolbar_recipe" />
<FrameLayout
android:id="@+id/content_frame"
android:paddingTop="?attr/actionBarSize"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</android.support.design.widget.CoordinatorLayout>
<android.support.design.widget.BottomNavigationView
android:id="@+id/bottom_navigation"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
app:menu="@menu/bottom_nav_menu"
app:labelVisibilityMode="unlabeled"
app:itemBackground="@color/colorPrimary"
app:itemIconTint="@color/bottom_nav_color"
app:itemTextColor="@color/bottom_nav_color" />
</RelativeLayout>
Без этого дополнения оно просто остается позади. Я работаю в Android 8+, но я не думаю, что это проблема, и у меня нет идей, как скоординировать эту ситуацию. Кто-нибудь испытывал это?
Спасибо за любой комментарий, особенно о том, почему это происходит, поскольку я не могу этого понять.