I am using a custom Toolbar for my Android App So that I can style my app title and while doing so I have noticed that the alignment of the title and the side navigation panel icon are not in an order and I am unable to figure out how to resolve this
This is the code of the xml layout
<androidx.drawerlayout.widget.DrawerLayout
android:id="#+id/drawer"
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:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<RelativeLayout
android:id="#+id/frame"
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<androidx.appcompat.widget.Toolbar
android:id="#+id/toolbar"
style="#style/Theme.AppCompat.DayNight.DarkActionBar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/white"
app:title=" "
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:layout_marginBottom="20dp"
android:fontFamily="#font/satisfy_regular"
android:text="CodeRem"
android:textColor="#3C4A63"
android:textSize="35sp"
/>
</androidx.appcompat.widget.Toolbar>
<androidx.fragment.app.FragmentContainerView
android:id="#+id/frag"
android:layout_below="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:name="com.example.coderem.Home"
/>
</RelativeLayout>
<com.google.android.material.navigation.NavigationView
android:id="#+id/nav"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
android:fitsSystemWindows="true"
app:headerLayout="#layout/nav_header"
app:menu="#menu/nav_menu" />
</androidx.drawerlayout.widget.DrawerLayout>
Related
i want to add bottom navigation bar along with side navigation bar but when i try i overlapped my toolbar. i try to add bottom navigation bar below the frame layout but it didnt work.
thanks in advance
<androidx.drawerlayout.widget.DrawerLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<androidx.coordinatorlayout.widget.CoordinatorLayout
android:layout_width="match_parent"
android:id="#+id/coordinate_layout"
android:layout_height="match_parent"
>
<androidx.appcompat.widget.Toolbar
android:layout_width="match_parent"
android:id="#+id/toolbar_layout"
android:layout_height="wrap_content"
android:minHeight="?attr/actionBarSize"
android:background="#color/cardview_dark_background"
android:theme="#style/ThemeOverlay.AppCompat.Dark"
/>
<FrameLayout
android:id="#+id/frame"
android:layout_width="fill_parent"
android:layout_height="match_parent"
/>
</androidx.coordinatorlayout.widget.CoordinatorLayout>
<com.google.android.material.navigation.NavigationView
android:layout_width="match_parent"
android:id="#+id/navigation_layout"
android:layout_height="match_parent"
app:headerLayout="#layout/drawer_header"
app:menu="#menu/menu_drawer"
android:layout_gravity="start"
/>
</androidx.drawerlayout.widget.DrawerLayout>
Place your FrameLayout and BottomNavigationView inside a LinearLayout. That should fix it.
<?xml version="1.0" encoding="utf-8"?>
<androidx.drawerlayout.widget.DrawerLayout 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">
<androidx.coordinatorlayout.widget.CoordinatorLayout
android:id="#+id/coordinate_layout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<androidx.appcompat.widget.Toolbar
android:id="#+id/toolbar_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/cardview_dark_background"
android:minHeight="?attr/actionBarSize"
android:theme="#style/ThemeOverlay.AppCompat.Dark" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<FrameLayout
android:id="#+id/frame"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1" />
<com.google.android.material.bottomnavigation.BottomNavigationView
android:id="#+id/bottom_navigation"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
app:labelVisibilityMode="labeled"
app:layout_anchorGravity="bottom"
app:menu="#menu/bottom_navigation_menu" />
</LinearLayout>
</androidx.coordinatorlayout.widget.CoordinatorLayout>
<com.google.android.material.navigation.NavigationView
android:id="#+id/navigation_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="start" />
</androidx.drawerlayout.widget.DrawerLayout>
I'm developing an Android application with the Android Studio template "Navigation Drawer Activity" but if I open the navigation drawer on a phone with Notch/display Cutouts the bigger status bar cover the top of the Navigation Drawer header.
How could I fix this?
Here are the Activity layout xml:
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout 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:id="#+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:openDrawer="start"
android:background="#color/colorPrimaryDark">
<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:fitsSystemWindows="true"
app:headerLayout="#layout/nav_header_main"
app:menu="#menu/activity_main_drawer" />
</android.support.v4.widget.DrawerLayout>
And the navigation drawer header layout:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="#dimen/nav_header_height"
android:background="#drawable/navbar_size_edit"
android:gravity="bottom"
android:orientation="vertical"
android:paddingBottom="#dimen/activity_vertical_margin_bar_bottom"
android:paddingLeft="#dimen/activity_horizontal_margin_bar"
android:paddingRight="#dimen/activity_horizontal_margin_bar"
android:paddingTop="#dimen/activity_vertical_margin_bar"
android:theme="#style/ThemeOverlay.AppCompat.Dark">
<ImageView
android:id="#+id/imageView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:contentDescription="#string/nav_header_desc"
android:paddingTop="#dimen/nav_header_vertical_spacing"
android:paddingBottom="#dimen/activity_vertical_margin_bar_bottom"
app:srcCompat="#mipmap/avatar_me_round" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="#dimen/nav_header_vertical_spacing"
android:text="#string/app_name"
android:textStyle="bold"
android:textAppearance="#style/TextAppearance.AppCompat.Body1" />
<TextView
android:id="#+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/app_version" />
</LinearLayout>
Change the attribute of android:fitsSystemWindows="true" to android:fitsSystemWindows="false". This is what worked for me.
To be more specific than Adarsha Nayak V, set android:fitsSystemWindows to false in your NavigationView:
<androidx.drawerlayout.widget.DrawerLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:openDrawer="start">
<!-- Other elements... -->
<com.google.android.material.navigation.NavigationView
android:id="#+id/nav_view"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
android:fitsSystemWindows="false"
app:headerLayout="#layout/navigation_drawer_header"
app:menu="#menu/navigation_drawer"/>
</androidx.drawerlayout.widget.DrawerLayout>
I want my header of my Navigation drawer to be below the statusbar. When searching for solutions, every result is about how to place it under the status bar. I have of course tried to "reverse" theese solutions to place the header below. But it hasn't worked and I'm testing it on a Samsung Galaxy S7 API 23
Right now it looks like this:
This is my layout containing DrawerLayout, NavigationView:
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout 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:id="#+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#00ffff"
android:fitsSystemWindows="true"
tools:openDrawer="start">
<include
android:id="#+id/toolbar_drawer_layout"
layout="#layout/navdrawer_toolbar"
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:background="#color/arion_darkgray"
android:fitsSystemWindows="true"
app:headerLayout="#layout/navdrawer_header"
app:itemBackground="#drawable/nav_drawer_selector"
app:itemIconTint="#fff"
app:itemTextColor="#fff"
app:menu="#menu/navdrawer_menu"
app:theme="#style/custom_navDrawer_style" />
</android.support.v4.widget.DrawerLayout>
Toolbar layout:
<?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=".MyHorseActivity">
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.v7.widget.Toolbar
android:id="#+id/myhorse_toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="#color/arion_darkblue">
<RelativeLayout
android:id="#+id/myhorse_toolbar_innerlayout"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="#android:color/transparent">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:paddingRight="70dp"
android:text="My Horse"
android:textColor="#fff"
android:textSize="24sp" />
<ImageView
android:backgroundTint="#ff0000"
android:layout_width="15dp"
android:layout_height="15dp"
android:layout_alignParentRight="true"
android:layout_centerInParent="true"
android:layout_marginRight="10dp"
android:background="#drawable/circle_shape" />
</RelativeLayout>
</android.support.v7.widget.Toolbar>
<include
layout="#layout/divider_lightblue"
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_alignParentBottom="true">
</include>
</android.support.design.widget.AppBarLayout>
<include
android:id="#+id/activity"
layout="#layout/myhorse_activity_" />
Much of this is auto generated by Android Studio after I created my NavigationDrawer Class from the wizard
You have not put your xml fully so I don't know whats wrong with your xml but if you want your navigation drawer below action bar then put your drawerlayout below your toolbar as follows
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<!--Start of the Toolbar and its items -->
<android.support.v7.widget.Toolbar
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center" />
<android.support.v4.widget.DrawerLayout
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"></LinearLayout>
<!--Used for displaying Navigation Drawer slide-->
<LinearLayout
android:id="#+id/navigation_drawer"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
android:orientation="vertical">
<FrameLayout
android:id="#+id/navigation_container"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>
</android.support.v4.widget.DrawerLayout>
</LinearLayout>
According to your edited question drawerlayout xml would be like
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<include
android:id="#+id/toolbar_drawer_layout"
layout="#layout/navdrawer_toolbar"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<android.support.v4.widget.DrawerLayout 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:id="#+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#00ffff"
android:fitsSystemWindows="true"
tools:openDrawer="start">
<include
android:id="#+id/activity"
layout="#layout/myhorse_activity_" />
<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:background="#color/arion_darkgray"
android:fitsSystemWindows="true"
app:headerLayout="#layout/navdrawer_header"
app:itemBackground="#drawable/nav_drawer_selector"
app:itemIconTint="#fff"
app:itemTextColor="#fff"
app:menu="#menu/navdrawer_menu"
app:theme="#style/custom_navDrawer_style" />
</android.support.v4.widget.DrawerLayout>
</LinearLayout>
and toolbar layout will be like
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout 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"
android:fitsSystemWindows="true"
tools:context=".MyHorseActivity">
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.v7.widget.Toolbar
android:id="#+id/myhorse_toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="#color/arion_darkblue">
<RelativeLayout
android:id="#+id/myhorse_toolbar_innerlayout"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="#android:color/transparent">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:paddingRight="70dp"
android:text="My Horse"
android:textColor="#fff"
android:textSize="24sp" />
<ImageView
android:layout_width="15dp"
android:layout_height="15dp"
android:layout_alignParentRight="true"
android:layout_centerInParent="true"
android:layout_marginRight="10dp"
android:background="#drawable/circle_shape"
android:backgroundTint="#ff0000" />
</RelativeLayout>
</android.support.v7.widget.Toolbar>
<include
layout="#layout/divider_lightblue"
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_alignParentBottom="true" />
</android.support.design.widget.AppBarLayout>
</android.support.design.widget.CoordinatorLayout>
I used the xml file below to achieve what you asked. But this way, the drawer opens below both the "status bar" and the "toolbar"
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:orientation="vertical"
android:layout_height="match_parent"
tools:context=".MainActivity">
<include xmlns:android="http://schemas.android.com/apk/res/android" layout="#layout/toolbar" />
<android.support.v4.widget.DrawerLayout
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/drawerLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity"
android:elevation="5dp">
<FrameLayout
android:id = "#+id/frameLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
>
</FrameLayout>
<ListView
android:background="#ffffff"
android:id = "#+id/drawerList"
android:layout_width="240dp"
android:layout_height="match_parent"
android:layout_gravity="left"
android:elevation="5dp"></ListView>
</android.support.v4.widget.DrawerLayout>
</LinearLayout>
I have custom toolbar and navigationview. But when I open navigationview, It looks full screen. I want it below of toolbar. How can I fix it ? Here is my activity_main.xml:
<android.support.v4.widget.DrawerLayout 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:id="#+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
android:id="#+id/container_app_bar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<include --> MY CUSTOM TOOLBAR
android:id="#+id/app_bar"
layout="#layout/app_bar" />
<FrameLayout
android:id="#+id/flContent"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<it.neokree.materialtabs.MaterialTabHost
android:id="#+id/materialTabHost"
android:layout_width="match_parent"
android:layout_height="48dp"
android:layout_below="#+id/app_bar"
app:accentColor="#color/colorPrimaryLight"
app:hasIcons="true"
app:iconColor="#android:color/white"
app:materialTabsPrimaryColor="#009688" />
</LinearLayout>
<android.support.v4.view.ViewPager
android:id="#+id/viewPager"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_below="#+id/materialTabHost"
android:layout_weight="1" />
</LinearLayout>
<android.support.design.widget.NavigationView
app:theme = "#style/NavigationViewStyle"
android:id="#+id/nvView"
android:layout_width="250dp"
app:itemIconTint="#color/colorPrimaryDark"
android:layout_height="match_parent"
android:layout_gravity="start"
android:background="#fff"
app:menu="#menu/drawer_view" />
I tried several way for show navigationdrawer below toolbar but I got errors at every turn. Help please?
Use LinearLayout or Relative Layout on top and put ur drawerlayout below what u want on top(toolbar, tab etc). and put ur content inside ur drawer layout.
<LinearLayout
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:orientation="vertical">
<LinearLayout
android:id="#+id/container_app_bar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<include --> MY CUSTOM TOOLBAR
android:id="#+id/app_bar"
layout="#layout/app_bar" />
<it.neokree.materialtabs.MaterialTabHost
android:id="#+id/materialTabHost"
android:layout_width="match_parent"
android:layout_height="48dp"
android:layout_below="#+id/app_bar"
app:accentColor="#color/colorPrimaryLight"
app:hasIcons="true"
app:iconColor="#android:color/white"
app:materialTabsPrimaryColor="#009688" />
</LinearLayout>
<android.support.v4.widget.DrawerLayout
android:id="#+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clickable="true"
android:focusableInTouchMode="true">
<android.support.v4.view.ViewPager
android:id="#+id/viewPager"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_below="#+id/materialTabHost"
android:layout_weight="1" />
<android.support.design.widget.NavigationView
android:id="#+id/navView"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
android:background="#android:color/white"
app:headerLayout="#layout/nav_header"
app:menu="#menu/menu_drawer" >
</android.support.design.widget.NavigationView>
</android.support.v4.widget.DrawerLayout>
</LinearLayout>
I want to create a navigation drawer that comes on top of the main activity.But with the code here
<android.support.v4.widget.DrawerLayout
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:layout_width="match_parent"
android:layout_height="match_parent"
>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
android:paddingBottom="#dimen/activity_vertical_margin"
tools:context=".invento">
<TextView android:text="#string/hello_world" android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</RelativeLayout>
<fragment
android:layout_width="#dimen/nav_drawerWidth"
android:layout_height="match_parent"
android:layout_gravity="start"
app:layout="#layout/fragment_navigation_drawer"
android:name="com.invento.defcomm.invento16.navigation_drawer"
tools:layout="#layout/fragment_navigation_drawer" />
I 'am getting the drawer below the action bar, not completely overlapping the entire activity. Please help me out on this and point out what am i doing wrong? Thanks....
Why don't you change your default action bar to a Toolbar. That way you can include the toolbar to your layout and keep the navigation drawer on top of the toolbar as well.
This is the code I use to add a toolbar:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<android.support.v7.widget.Toolbar
android:id="#+id/toolbar_actionbar"
style="#style/ToolBarStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/colorPrimary"
android:minHeight="#dimen/abc_action_bar_default_height_material"/>
</LinearLayout>
and then I include the above xml in my layout everywhere.
<include
android:id="#+id/toolbar"
layout="#layout/toolbar_default"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="false"/>
So in your xml, you can simply do this:
<android.support.v4.widget.DrawerLayout
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:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
android:paddingBottom="#dimen/activity_vertical_margin"
tools:context=".invento">
<include
android:id="#+id/toolbar"
layout="#layout/toolbar_default"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="false"/>
<TextView android:text="#string/hello_world" android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<fragment
android:layout_width="#dimen/nav_drawerWidth"
android:layout_height="match_parent"
android:layout_gravity="start"
android:layout_alignParentTop="true"
app:layout="#layout/fragment_navigation_drawer"
android:name="com.invento.defcomm.invento16.navigation_drawer"
tools:layout="#layout/fragment_navigation_drawer" />
</RelativeLayout>
And in your Activity, assign the Toolbar as your ActionBar:
mToolbar = (Toolbar) findViewById(R.id.toolbar_actionbar);
mToolbar.setLogo(getResources().getDrawable(R.drawable.ic_launcher)); // Your Logo
mToolbar.setTitle("Title"); // Your Title
setSupportActionBar(mToolbar);
Try this,
<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"
android:fitsSystemWindows="true">
<!-- The main content view -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<!-- Toolbar instead of ActionBar so the drawer can slide on top -->
<android.support.v7.widget.Toolbar
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="#dimen/abc_action_bar_default_height_material"
android:background="?attr/colorPrimary"
android:minHeight="?attr/actionBarSize"
app:theme="#style/ThemeOverlay.AppCompat.Dark.ActionBar"
app:popupTheme="#style/ThemeOverlay.AppCompat.Light"
app:titleTextAppearance="?android:attr/textAppearanceMedium" />
<!-- Real content goes here -->
<FrameLayout
android:id="#+id/content"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1" />
</LinearLayout>
<android.support.design.widget.NavigationView
android:id="#+id/navigation_view"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
app:menu="#menu/drawer" />