How to

0

1

First up, modify your layout to be a drawer layout, and give yourself two children to work with:

2

If you’re using this code, you’ll need some layout to fill in the ListView that appears in the drawer:

3

We need a couple of strings to describe the open/close actions, so add these to your strings.xml file:

4

You’ll need one of these in your drawables-hdpi directory:

Really, the proper way to do this is to create a few assets at the appropriate scales, and drop them into each of the drawables directories so that they all look right. Official assets can be downloaded here.

I’ll also note that the asset may not be in my github repo yet for some reason. Android Studio didn’t pick it up as a new file, and while I’ll get it pushed up shortly, if you download this before I fix it, you may be missing that asset.

5

Now, we can use this in the code. This basically enables the icon in the ActionBar to be used to toggle the drawer, along with swiping from the left edge. It also adds a simple ListView within the drawer, and allows user to click those items to toast the name of the app, and change the title in the ActionBar.