The navigation drawer is a panel that transitions in from the left edge of the screen and displays the app's main navigation options.
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:
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" android:layout_height="match_parent"> <FrameLayout android:id="@+id/drawerContent" android:layout_width="match_parent" android:layout_height="match_parent" /> <ListView android:id="@+id/drawerList" ...