What are NavigationDrawer and DrawerLayout in android?

Hey, what’s up, guys. You use lots of android apps these days. You have probably seen that three horizontal bars on the top-left side of some app. When you touch the bars or when you swipe from the left edge of of the activity a layout slides out , that’s NavigationDrawer.

NavigationDrawer is implemented by adding DrawerLayout to the activity.

So let’s see its official definition first.

Navigation drawers provide access to destinations and app functionality, such as switching accounts. They can either be permanently on-screen or controlled by a navigation menu icon.

Now let me give you a visual idea of NavigationDrawer.

Now that you have an idea of NavigationDrawer, let’s see how can you implement NavigationDrawer in your app.

I have created a simple app that demonstrate DrawerLayout and NavigationDrawer. You can find the code for the app on my github page.- Click here to see the code.

Here’s the steps to follow –

  1. Create basic fragments and activities for the app’s content.
  2. Create options for the drawer (menu_navigation.xml – see the code)
  3. Create a header for the drawer (navigation_header.xml).
  4. Add the Navigation drawer to the app’s main activity.

Here’s the screenshot of the final app.

That’s all about Android NavigationDrawer and DrawerLayout.

Goodbye.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: