I have two navigation menus in a drawer layout, Left and Right. I want the Left Navigation menu below the toolbar and Right Navigation Menu over the toolbar as shown in the diagram below:
How to achieve this?
My Layout is:
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/id_home_start"
xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:scrollbars="vertical">
<LinearLayout
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"
xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
tools:context="com.artifex.mupdfdemo.HomeStart">
<include
android:layout_height="wrap_content"
android:layout_width="match_parent"
layout="@layout/toolbar_layout" />
</LinearLayout>
<android.support.design.widget.NavigationView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="50dp"
android:id="@+id/home_menu"
android:layout_gravity="start">
<android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
card_view:cardUseCompatPadding="true">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<ImageView
android:layout_width="40dp"
android:layout_height="40dp"
android:src="@drawable/upld"
android:layout_marginLeft="1dp"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/my_uploads"
android:text="My Uploads"
android:textColor="#000000"
android:textStyle="bold"
android:textSize="20dp"
android:paddingTop="10dp"
android:paddingBottom="10dp"
android:gravity="center"
/>
</LinearLayout>
</android.support.v7.widget.CardView>
</android.support.design.widget.NavigationView>
<android.support.design.widget.NavigationView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/profile_menu"
android:layout_gravity="end">
<android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
card_view:cardUseCompatPadding="true">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<ImageView
android:layout_width="30dp"
android:layout_height="30dp"
android:src="@drawable/options"
android:layout_marginLeft="1dp"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/update_profile"
android:text="Update Profile"
android:textColor="#000000"
android:textStyle="bold"
android:textSize="20dp"
android:paddingTop="10dp"
android:paddingBottom="10dp"
android:gravity="center"
/>
</LinearLayout>
</android.support.v7.widget.CardView>
</android.support.design.widget.NavigationView>
</android.support.v4.widget.DrawerLayout>
and my Java Code is:
Toolbar toolbar;
DrawerLayout drawerLayout;
ActionBarDrawerToggle actionBarDrawerToggle;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_home_start);
toolbar = (Toolbar) findViewById(R.id.toolbar);
toolbar.setTitle("Home");
setSupportActionBar(toolbar);
drawerLayout = (DrawerLayout) findViewById(R.id.id_home_start);
actionBarDrawerToggle=new ActionBarDrawerToggle(this, drawerLayout, toolbar, R.string.drawer_open, R.string.drawer_close);
drawerLayout.setDrawerListener(actionBarDrawerToggle);
}
@Override
protected void onPostCreate(Bundle savedInstanceState){
super.onPostCreate(savedInstanceState);
actionBarDrawerToggle.syncState();
}