1

i'm trying to set Navigation drawer behind Toolbar , i already tried to set android:layout_marginTop="@dimen/abc_action_bar_default_height_material" to NanvigationView but nothing changed and also i follow this Navigation Drawer Below Toolbar but doesn't work

enter image description here

activity_main.xml :

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/top_parent"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:context=".MainActivity">
<include
    layout="@layout/app_bar_main"
    android:layout_width="match_parent"
    android:layout_height="match_parent" />
<android.support.v4.widget.DrawerLayout
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:openDrawer="start">
<android.support.design.widget.NavigationView
    android:id="@+id/nav_view"
    android:layout_width="wrap_content"
    android:layout_height="match_parent"
    android:layout_gravity="start"
    android:fitsSystemWindows="false"
    android:theme="@style/NavigationView"
    android:background="#2b2b2b"
    app:itemTextColor="#FFF"
    app:menu="@menu/activity_main_drawer" />
</android.support.v4.widget.DrawerLayout>
</RelativeLayout>

App_bar_main.xml :

<?xml version="1.0" encoding="utf-8"?>
 <android.support.design.widget.CoordinatorLayout    
 xmlns:android="http://schemas.android.com/apk/res/android"
 xmlns:app="http://schemas.android.com/apk/res-auto"
 xmlns:tools="http://schemas.android.com/tools"
 android:layout_width="match_parent"
 android:layout_height="match_parent"
 android:fitsSystemWindows="true"
 tools:context="maa.a4kandhdwallpapers.MainActivity">
 <android.support.design.widget.AppBarLayout
     android:layout_width="match_parent"
     android:layout_height="wrap_content"
      android:theme="@style/AppTheme.AppBarOverlay">
    <android.support.v7.widget.Toolbar
        android:id="@+id/toolbar"
        android:layout_width="match_parent"
        android:layout_height="?attr/actionBarSize"
        android:background="?attr/colorPrimary"
        app:popupTheme="@style/AppTheme.PopupOverlay" />
  </android.support.design.widget.AppBarLayout>
    <include layout="@layout/content_main" />
</android.support.design.widget.CoordinatorLayout>
Community
  • 1
  • 1
MrMR
  • 279
  • 6
  • 16
  • @MikeM. i folloz the **Approved answer** but doesn't work – MrMR Apr 29 '17 at 14:32
  • @MikeM. Please check check my update code i tried to set this : `RelativeLayout ----Toolbar ----DrawerLayout ---ContentView ---DrawerList ` – MrMR Apr 29 '17 at 14:38
  • @MikeM. Unfortunately she didn't work , i tried to put `` inside the `` before the `` as are you said but doesn't work when i run it still the same nothing changed – MrMR Apr 29 '17 at 15:02
  • @MikeM. I know I bothered you but I added `app_bar_main` please help me – MrMR Apr 29 '17 at 15:13
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/142969/discussion-between-ali-ila-and-mike-m). – MrMR Apr 29 '17 at 15:18

1 Answers1

0

Try next code for activity_main.xml :

<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout
android:id="@+id/drawer_layout"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:openDrawer="start">

<include
    layout="@layout/app_bar_main"
    android:layout_width="match_parent"
    android:layout_height="match_parent" />

<android.support.design.widget.NavigationView
android:id="@+id/nav_view"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
android:theme="@style/NavigationView"
android:background="#2b2b2b"
app:itemTextColor="#FFF"
app:menu="@menu/activity_main_drawer" 
android:layout_marginTop="@dimen/appbar_height"/>

appbar_height - your value in dimen.xml. It can be equal to ?actionBarSize.

Sergio
  • 27,326
  • 8
  • 128
  • 149