Search code examples
androidnavigation-drawermaterial-designandroid-design-libraryandroid-navigationview

How to make the second navigation drawer NOT cover the app bar?


I've been dealing with this DrawerLayout and NavigationViews and I don't seem to ba able to solve this issue. According to google guidelines the first navbar should cover the app bar and the second one should NOT.

How I achieve that? Whatever I do it either makes both of them cover or both of them not cover the app bar.

Since navigation view is pretty new I could not get any suitable answer googling and exploring overflow.com. Any guide, help, tutorial, sample... is highly appreciated.

Thanks before.

Here is my activity.xml

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

    <!-- As the main content view, the view below consumes the entire
         space available using match_parent in both dimensions. -->
    <LinearLayout
            android:orientation="vertical"
            android:id="@+id/container"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            >
        <include
                android:id="@+id/app_bar"
                layout="@layout/app_bar">
        </include>
    </LinearLayout>


    <android.support.design.widget.NavigationView
            android:id="@+id/nav_draw"
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:layout_gravity="start"
            app:headerLayout="@layout/drawer_header"
            app:menu="@menu/drawer"/>
    <android.support.design.widget.NavigationView
            android:id="@+id/second_nav_draw"
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:layout_gravity="end"
            />
</android.support.v4.widget.DrawerLayout>

Solution

  • I don't know about NavigationView, but with other views a simple margin used to work. Try:

    android:layout_marginTop="?attr/actionBarSize"