Search code examples
androidnavigationbargoogle-keep

Toolbar was hidden behind the navigation drawer


    <android.support.v4.widget.DrawerLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:app="http://schemas.android.com/apk/res-auto"
        android:id="@+id/drawer_layout"
        android:layout_width="match_parent"
        android:layout_height="match_parent">
     <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical">

    <android.support.v7.widget.Toolbar
            android:id="@+id/toolbar"
            android:layout_height="wrap_content"
            app:theme="@style/ThemeOverlay.AppCompat.ActionBar"
            android:minHeight="?attr/actionBarSize"
            android:layout_width="match_parent"
            android:background="@color/main_color"
            >
        </android.support.v7.widget.Toolbar>


        <FrameLayout
            android:id="@+id/left_drawer"
            android:layout_width="300dp"
            android:layout_height="match_parent"
            android:layout_gravity="left" />
        <FrameLayout
            android:id="@+id/view_main"
            android:layout_width="match_parent"
            android:layout_height="match_parent" />


    </LinearLayout>
</android.support.v4.widget.DrawerLayout>

I am trying to configure the following components

Toolbar (Appcompat v7 version)

Navigation Drawer

but my toolbar should be behind navigationbar like google keep?


Solution

  • Put your Drawer below main View :

    <android.support.v4.widget.DrawerLayout
            xmlns:android="http://schemas.android.com/apk/res/android"
            xmlns:app="http://schemas.android.com/apk/res-auto"
            android:id="@+id/drawer_layout"
            android:layout_width="match_parent"
            android:layout_height="match_parent">
         <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:orientation="vertical">
    
        <android.support.v7.widget.Toolbar
                android:id="@+id/toolbar"
                android:layout_height="wrap_content"
                app:theme="@style/ThemeOverlay.AppCompat.ActionBar"
                android:minHeight="?attr/actionBarSize"
                android:layout_width="match_parent"
                android:background="@color/main_color"
                >
            </android.support.v7.widget.Toolbar>
    
               <FrameLayout
                android:id="@+id/view_main"
                android:layout_width="match_parent"
                android:layout_height="match_parent" />
            <FrameLayout
                android:id="@+id/left_drawer"
                android:layout_width="300dp"
                android:layout_height="match_parent"
                android:layout_gravity="left" />
    
    
    
        </LinearLayout>
    </android.support.v4.widget.DrawerLayout>
    

    Lower down in the file means higher up in the Z-axis.