NavigationView隐藏在MapView后面

问题描述 投票:0回答:1

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

<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" />
android navigation-drawer mapbox
1个回答
0
投票

首先,您的布局应具有根布局,例如

<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>

您也可以使用DrawerLayout

另外,请参考此链接clickHere以更好地理解带有工具栏的地图

© www.soinside.com 2019 - 2024. All rights reserved.