1

My hamburger menu is hidden behind my MapView, but I want it to be in front of the MapView. I have used this same code in other programs successfully.

<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" />
Ryan M
  • 18,333
  • 31
  • 67
  • 74
  • Assuming the root in that layout is a ``, it should have only two direct children – the main content and the drawer, and the drawer must be listed last within the ``. Move your `` into the ``, and add an `android:layout_below="@+id/toolbar"` attribute to it. – Mike M. Apr 07 '20 at 03:15
  • That didn't work – Adam Perison Apr 07 '20 at 03:34
  • Have a look at [this post](https://stackoverflow.com/q/19314383), then. Apparently there are issues with maps' renderings. You need to keep the general layout I described above, though; i.e., only the main content and drawer children, and the drawer listed last. – Mike M. Apr 07 '20 at 03:45

1 Answers1

2

First, your layout should have a root layout like

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

You can also use DrawerLayout

Also, refer this link clickHere for better understanding of map with toolbar

Mob Dev
  • 854
  • 4
  • 9