Two Drawer Layouts from Same Side in Xamarin.Android


In one of the projects, client require to built a design where a secondary drawer will opened over already opened primary drawer.

As per Android Material Design guidelines its not recommended and its not implemented in android.support.v4.widget.DrawerLayout. If we try to implement it in code like following, it throws exception, only one drawer can be shown.

<?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"
    android:id="@+id/drawer_layout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="true">
    <!-- Layout to contain contents of main body -->
    <FrameLayout
        android:id="@+id/content_frame"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />
    <!-- First container for drawer contents -->
    <android.support.design.widget.NavigationView
        android:id="@+id/first_nav_view"
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:layout_gravity="start"
        android:fitsSystemWindows="true" />
    <!-- Second container for drawer contents -->
    <android.support.design.widget.NavigationView
        android:id="@+id/second_nav_view"
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:layout_gravity="start"
        android:fitsSystemWindows="true" />
</android.support.v4.widget.DrawerLayout>

To show both drawers from same side we need to extend the android.support.v4.widget.DrawerLayout to handle the navigation of secondary drawer over primary.

Related Posts

Xamarin Android FullScreen Video View

Xamarin Android Binding for FullscreenVideoView.

Xamarin Android Native Sharing

Different ways of sharing UI in Xamarin Android.

Xamarin.Forms 4.0.0-pre1

Big Changes in Xamarin.Forms 4.0 Prompt Early Preview.