Android-Developer and HpTerm helped me in the right rirection, by
- Pointing out this is indeed NavigationDrawer specific (which I was already using as in Google's example)
- Telling where to find the
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.
drawerToggle = new ActionBarDrawerToggle(this,
drawerLayout,
R.drawable.ic_navigation_drawer,
R.string.side_menu_open,
R.string.side_menu_closed) {
// ...
};
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.
@Override
protected void onCreate(Bundle savedInstanceState) {
// ...
getActionBar().setDisplayHomeAsUpEnabled(true); // also required
if (Build.VERSION.SDK_INT >= 18) {
getActionBar().setHomeAsUpIndicator(
getResources().getDrawable(R.drawable.ic_navigation_drawer));
}
}
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. With setDisplayHomeAsUpEnabled(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:
// Defer code dependent on restoration of previous instance state.
drawerLayout.post(new Runnable() {
@Override
public void run() {
mDrawerToggle.syncState();
}
});
With that included, calling setHomeAsUpIndicator()
is not needed.
NavigationDrawer
or you just want the same look as in the picture? The drawer indicator is a custom icon which not only Google uses to indicate that pressing home button from theActionBar
will open a menu. – CrawlNavigationDrawer
and I want the same look as in the picture. :) – Sprayberry