O'Reilly logo

Xamarin Mobile Development for Android Cookbook by Matthew Leibowitz

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Adding a navigation drawer with fragments

The navigation drawer is a panel that transitions in from the left edge of the screen and displays the app's main navigation options.

How to do it...

We can add a navigation drawer to our app by setting the DrawerLayout type as the root layout container, with the contents of the drawer and the main content as subviews:

  1. The DrawerLayout type should be the root of our layout file, with two subviews: the first is the main content and the second is the drawer. Let's take a look at the following code snippet:
    <?xml version="1.0" encoding="utf-8"?> <android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/drawerLayout" android:layout_width="match_parent" ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required