At least Gmail and Youtube Android apps use a side menu (navigation drawer?) that opens by swiping, or by clicking the app icon (home button):
Is the menu indicator / icon in the screenshot above a ready-made part of Android SDK? (Or a custom icon Google uses in their apps?) In any case, what's the easiest way to get your home button to look like that, i.e., like it opens a menu?
(targetSdkVersion
18; minSdkVersion
14)
Resolution
Finally got it working. What was missing for me was 1) the actual icon and 2) deferred call to syncState()
on the ActionBarDrawerToggle
.
Android-Developer and HpTerm helped me in the right rirection, by
ic_drawer.png
icon (→ Android Asset Studio)Now, unfortunately, creating ActionBarDrawerToggle like below seems not to be enough. At least on my Nexus 7 (API 18) test device.
Partial solution (API level 18+)
I found one way to make the indicator show up though:
setHomeAsUpIndicator()
. The downside: that method was added in API level 18.So now the question remains: how to make this work (in my case) for API levels 14 through 17?
I verified on a 4.1.2 (API 16) device that the
ic_drawer
icon does not show up. WithsetDisplayHomeAsUpEnabled(true)
I get the normal "home" icon (small arrow pointing left) and without it, the space left to my app icon remains blank.Final solution
Got it working using the edited version of Android-Developer's answer.
Quite curiously, what was missing from my ActionBarDrawerToggle initialisation code was this:
With that included, calling
setHomeAsUpIndicator()
is not needed.To create similar implementation / look in your application you should use
ActionBarDrawerToggle
and set your custom icon as indicator next to ActionBar home button. For example :Where
R.drawable.ic_drawer
is actually the icon to use as indicator. You can find it in Android Asset Studio; see Navigation Drawer Indicator.References
The keyword here is
NavigationDrawer
; there's a full working code example on the Android developer site.READ THE END OF THE LINK GIVEN : Open and Close with the App Icon
The following code is copied from there
Some files are available as download and the small 3 lines with the animation effect is fully exemplified.
You have to copy thoses files in the corresponding
drawable
folder. Depending on the theme you use, dark or light you have a different set of icons.In my case I simply copied the
drawer_shadow.9.png
andic_drawer.png
in the drawable folder and followed the example and everything works just fine.The icons are available in the link I provided, but they are NOT in the "Action Bar Icon Pack", they are in the sample app in the corresponding res/drawable folders.