Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/180.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 为什么我的ButoBar在屏幕中间?_Android_Android Layout_Navigation Drawer_Bottombar - Fatal编程技术网

Android 为什么我的ButoBar在屏幕中间?

Android 为什么我的ButoBar在屏幕中间?,android,android-layout,navigation-drawer,bottombar,Android,Android Layout,Navigation Drawer,Bottombar,我同时使用NavigationDrawer和BottomNavigationView。但在添加导航抽屉后,底部导航的位置发生了变化。我该如何解决这个问题?我假设这个问题是由我的xml文件引起的 活动\u main.xml <android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android

我同时使用NavigationDrawer和BottomNavigationView。但在添加导航抽屉后,底部导航的位置发生了变化。我该如何解决这个问题?我假设这个问题是由我的xml文件引起的

活动\u main.xml

<android.support.v4.widget.DrawerLayout  xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/activity_main"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:openDrawer="start"
tools:context="com.example.yunus.ototakip.MainActivity">

<include
    layout="@layout/app_bar_navigation_bar"
    android:layout_width="match_parent"
    android:layout_height="match_parent" />

<android.support.design.widget.NavigationView
    android:id="@+id/nav_view"
    android:layout_width="wrap_content"
    android:layout_height="match_parent"
    android:layout_gravity="start"
    android:fitsSystemWindows="true"
    app:headerLayout="@layout/nav_header_navigation_bar"
    app:menu="@menu/activity_navigation_bar_drawer" />
<FrameLayout
    android:id="@+id/main_container"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_alignParentTop="true"
    android:layout_alignParentStart="true">
</FrameLayout>

<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:itemBackground="@color/colorPrimary"
    app:itemIconTint="@color/beyaz"
    app:itemTextColor="@color/beyaz"
    app:menu="@menu/bottombar_menu" />


使用android:layout\u gravity=“bottom”而不是layout\u alignParentBottom,因为它是用于RelativeLayout而不是android.support.v4.widget.DrawerLayout。

将您的
BottomNavigationView
附加到
CoordinatorLayout
中(或您在app\u bar\u navigation\u bar布局中的任何视图组)不要
DrawerLayout
,并添加适当的重力标签

android:layout_gravity="bottom"

尝试使用这两种方法中的任何一种=

android:layout_gravity="bottom"


你知道
layout\u alignParentBottom
用于
RelativeLayout
?啊,是的,但我该如何在抽屉布局的底部设置它?我得到了这个错误:索引3处的底部导航视图没有有效的布局\u重力-必须是gravity.LEFT、gravity.RIGHT或gravity.NO\u gravity。谢谢你,伙计。
android:gravity="bottom"