Android NavigationView隐藏在MapView后面

Android NavigationView隐藏在MapView后面,android,navigation-drawer,mapbox,Android,Navigation Drawer,Mapbox,我的汉堡包菜单隐藏在我的地图视图后面,但我希望它位于地图视图前面。我已经在其他程序中成功地使用了相同的代码 <RelativeLayout android:layout_width="match_parent" android:layout_height="match_parent"> <androidx.appcompat.widget.Toolbar android:id="@+id/toolbar" androi

我的汉堡包菜单隐藏在我的
地图视图
后面,但我希望它位于
地图视图
前面。我已经在其他程序中成功地使用了相同的代码

<RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent">


    <androidx.appcompat.widget.Toolbar
        android:id="@+id/toolbar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:foregroundGravity="top|left" />

</RelativeLayout>

<com.google.android.material.navigation.NavigationView
    android:id="@+id/navigationView"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_gravity="start"
    android:translationZ="100dp"
    android:visibility="visible"
    app:headerLayout="@layout/header"
    app:itemTextColor="#fff"
    app:menu="@menu/menu_item" />

<com.mapbox.mapboxsdk.maps.MapView
    android:id="@+id/mapView"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:translationZ="100dp" />

首先,您的布局应该有一个根布局,如

<LinearLayout
  android:layout_width="match_parent"
    android:layout_height="match_parent"
    orientation="vertical">

<RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent">


    <androidx.appcompat.widget.Toolbar
        android:id="@+id/toolbar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:foregroundGravity="top|left" />

</RelativeLayout>

<com.google.android.material.navigation.NavigationView
    android:id="@+id/navigationView"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_gravity="start"
    android:translationZ="100dp"
    android:visibility="visible"
    app:headerLayout="@layout/header"
    app:itemTextColor="#fff"
    app:menu="@menu/menu_item" />

<com.mapbox.mapboxsdk.maps.MapView
    android:id="@+id/mapView"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:translationZ="100dp" />
</LinearLayout>


为了更好地理解带有工具栏的地图

,假设该布局中的根是一个
,它应该只有两个直接子级–主要内容和抽屉,抽屉必须列在
中的最后一个。将您的
移动到
中,并在其下方添加一个
android:layout_=“@+id/toolbar”
属性。这不起作用,请查看。显然地图的渲染有问题。不过,您需要保持我上面描述的总体布局;i、 例如,只有主要内容和抽屉子项,并且抽屉列在最后。