Android Coder: Material Design Navigation Drawer Distinctions

NixMashup Links for Android now supports Material Design and with it a completely rewritten Navigation Drawer. We'll look at some of the differences between the Material Design Navigation Drawer and its KitKat predecessor.

Here's a screenshot of the new Material Design Drawer in an Android 5.0 Emulator.

The Layout XML File

The MainActivity Layout file shows a number of differences. First you'll see we're going to include Material Design's implementation of the ActionBar, now the Toolbar. We're using the support.v4 DrawerLayout as before, but instead of using a </ ListView > as we did in KitKat we're using a RecyclerView.

BaseActivity Class and the New Toolbar

The Activity classes in NixMashup Links which use the Navigation Drawer derive from BaseActivity, and the class declaration shows us other differences from KitKat. To use the Material Design Toolbar we inherit from ActionBarActivity (instead of FragmentActivity or Activity.) We also implement a method from a CategoryAdapter class we create to manage the new RecyclerView we're using in the drawer (as opposed to the simple ListView in KitKat.)

Here's the KitKat base class declaration.

The Navigation Drawer Helper Class

Like the KitKat Version we're going to use a Navigation Drawer Helper Class to more easily support multiple activities. Notice we'll manage the Toolbar from the helper class as well.

To use the helper from the we pass the activity in the init() and the call the helper onClick().

A very important element of the NixMashup Links Material Design Navigation Drawer is the CategoryAdapter to display the links by drawer category. We've covered the basics of the updated navigation drawer here and will look at the CategoryAdapter as it applies to the new RecyclerView-based category list in a separate post.

Android Coder Notes for this Post

The Material Design Navigation Drawer can be found in the Version 1.2 Branch in the project's GitHub repository.

Posted January 09, 2015 11:36 AM EST

More Like This Post