Drawer Layout

Learn how to create a drawer layout in our application.

We'll cover the following...

Drawer layout

The drawer layout is a menu container that contains navigation destinations. A user can slide it open and close after use. They’re normally recommended for applications with more than five fragments. Although our application has only three destinations, let’s learn how to create and use it.

Let’s go through the code.

Layouts

Press + to interact
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">
<item
android:id="@+id/github_repo"
android:title="@string/github_repository"
android:icon="@drawable/git"/>
<item
android:id="@+id/rate_app"
android:title="@string/rate_this_app"
android:icon="@drawable/star"/>
<item
android:id="@+id/developer"
android:title="@string/about_developer"
android:icon="@drawable/programmer"/>
</menu>

In the code snippet above, we have a menu layout called navigation_drawer_menu.xml that contains different options that a user can click to navigate to ...