In this article, you will learn how to create Drawer Layout using Material Design in Xamarin.Android.
Open VS > File > Cross-Platform > Blank App (Native Portable).

Step 2- Creating required styles

Open styles and write a custom style below. Just take a look below.

So, to customize, we need to set and create our custom theme (if you want to) in styles.
- <style name="MyTheme" parent="Theme.AppCompat.Light.NoActionBar">
- <item name="windowNoTitle">true</item>
- <item name="windowActionBar">false</item>
- <item name="colorPrimary">#16A085</item>
- <item name="colorPrimaryDark">#1976D2</item>
- <item name="colorAccent">#FF4081</item>
- <item name="drawerArrowStyle">@style/MyDrawerArrowStyle</item>
- </style>
- <style name="MyDrawerArrowStyle" parent="Widget.AppCompat.DrawerArrowToggle">
- <item name="color">#F5F5F5</item>
- <item name="spinBars">true</item>
- </style>
So, I have overriden all values which are required with my custom values.
Step 2 - Creating Drawer Layout
Now, let's add a new layout. Right click >> Add New >> Android Layout >> DrawerLayout.axml.

Now, we need to add the required NuGet packages before we start writing UI. So, download the following NuGet packages.
- Xamarin.Android.Support.v4 version="25.4.0.2"
- Xamarin.Android.Support.v7.AppCompat version="25.4.0.2"
- Xamarin.Android.Support.Fragment version="25.4.0.2"
- Refractored.Controls.CircleImageView( for circle image view in left drawer)
Now, open DrawerLayout.axml and write the following UI Code.
- <?xml version="1.0" encoding="utf-8"?>
- <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:app="http://schemas.android.com/apk/res-auto"
- android:orientation="vertical"
- android:layout_width="fill_parent"
- android:layout_height="fill_parent">
- <android.support.v7.widget.Toolbar
- android:id="@+id/toolbar"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:minHeight="?attr/actionBarSize"
- android:background="?attr/colorPrimary"
- app:theme="@style/MyTheme"
- app:layout_scrollFlags="scroll|enterAlways"
- app:popupTheme="@style/ThemeOverlay.AppCompat.Dark" />
- <android.support.v4.widget.DrawerLayout
- android:id="@+id/drawer_layout"
- android:layout_width="match_parent"
- android:layout_height="match_parent">
- <!-- The Main Content View -->
- <RelativeLayout
- android:layout_width="match_parent"
- android:layout_height="match_parent">
- <android.support.design.widget.AppBarLayout
- android:layout_height="wrap_content"
- android:layout_width="match_parent"
- android:id="@+id/toolbar_layout">
- <!-- you can create separately and use it here Like this ,but for now i am doing inline for toolbar-->
- <!--<include
- layout="@layout/toolbar" />-->
- </android.support.design.widget.AppBarLayout>
- <FrameLayout
- android:id="@+id/content_frame"
- android:layout_below="@id/toolbar_layout"
- android:layout_width="match_parent"
- android:layout_height="match_parent" />
- </RelativeLayout>
- <!-- The Left Navigation Drawer -->
- <android.support.design.widget.NavigationView
- android:id="@+id/nav_view"
- android:layout_height="match_parent"
- android:layout_width="240dp"
- android:layout_gravity="start"
- app:menu="@layout/left_menu_items"
- app:headerLayout="@layout/nav_header_main"
- android:fitsSystemWindows="true" >
- </android.support.design.widget.NavigationView>
- </android.support.v4.widget.DrawerLayout>
- </LinearLayout>
Note
Action Bar is deprecated, so we are using toolbar (which builds a new control on top of ActionBar)
So I referred to my Style for a toolbar like this

So first, we will create a UI for Header menu. Add a new layout file, say nav_header_main.
- <?xml version="1.0" encoding="utf-8"?>
- <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:app="http://schemas.android.com/apk/res-auto"
- android:id="@+id/view_container"
- android:layout_width="match_parent"
- android:layout_height="@dimen/nav_header_height"
- android:gravity="bottom"
- android:orientation="vertical"
- android:theme="@style/ThemeOverlay.AppCompat.Dark">
- <LinearLayout
- android:layout_width="220dp"
- android:layout_height="wrap_content"
- android:layout_centerVertical="true"
- android:orientation="vertical"
- android:padding="@dimen/activity_horizontal_margin">
- <refractored.controls.CircleImageView
- xmlns:app="http://schemas.android.com/apk/res-auto"
- android:id="@+id/profile_image"
- android:layout_width="96dp"
- android:layout_height="96dp"
- android:src="@drawable/profile"
- app:civ_border_width="2dp"
- app:civ_border_color="#D40047"/>
- <TextView
- android:id="@+id/name"
- android:text="Nina"
- android:textColor="#1E1E1E"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:paddingTop="@dimen/nav_header_vertical_spacing"
- android:textAppearance="@style/TextAppearance.AppCompat.Body1" />
- <TextView
- android:id="@+id/names"
- android:layout_below="@id/name"
- android:text="[email protected]"
- android:textColor="#B0B0B0"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:textAppearance="@style/TextAppearance.AppCompat.Body1" />
- </LinearLayout>
- </RelativeLayout>
Put all the images in Drawable folder and refer to it like this. If you're supporting multiple resolutions, put all respective scaled images in remaining Drawable folders. For now, I am adding to drawable only.

android:src="@drawable/profile"
app:headerLayout="@layout/nav_header_main"
Now, we have to create menu items. So, add another layout file and name it as left_menu_items.axml.
- <?xml version="1.0" encoding="UTF-8" ?>
- <menu xmlns:android="http://schemas.android.com/apk/res/android">
- <group android:checkableBehavior="single">
- <item
- android:id="@+id/nav_home"
- android:icon="@drawable/ic_Order"
- android:title="Orders" />
- <item
- android:id="@+id/nav_friends"
- android:icon="@drawable/ic_Redeem"
- android:title="Redeem" />
- <item
- android:id="@+id/nav_profile"
- android:icon="@drawable/ic_today"
- android:title="Notifications" />
- </group>
- <item android:title="Today">
- <menu>
- <item
- android:icon="@drawable/ic_test"
- android:title="Tasks"
- android:checkable="true" />
- <item
- android:icon="@drawable/ic_forum"
- android:title="Messages"
- android:checkable="true" />
- </menu>
- </item>
- </menu>





Bhavya JoshiPosted Jul 22, 2019, 8:11 AM
Dude, please share the code
rajesh waranPosted Jul 6, 2018, 1:49 AM
Could you share files with me?
satya mPosted Jun 11, 2018, 4:36 AM
Could you share the code?
jesus garciaPosted Mar 27, 2018, 6:21 PM
Could you share the code?
kiran patilPosted Nov 8, 2017, 1:32 PM
Can you give me project files for this article, because cannot find what is VAMOS and no file for dimen