I can't get the new lollipop drawer toggle to work.
I did this:
void setupToolbar() {
setToolbarAsActionBar();
setupDrawerToggle();
}
public void setToolbarAsActionBar() {
toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
}
void setupDrawerToggle() {
drawerToggle = new ActionBarDrawerToggle(this, drawerLayout, toolbar, R.string.overview_title, R.string.overview_title) {
@Override
public void onDrawerClosed(View drawerView) {
super.onDrawerClosed(drawerView);
}
@Override
public void onDrawerOpened(View drawerView) {
super.onDrawerOpened(drawerView);
}
};
drawerLayout.setDrawerListener(drawerToggle);
drawerToggle.setDrawerIndicatorEnabled(true);
drawerToggle.syncState();
}
The hamburger icon is there, I see it animating when sliding drawer out by swiping finger. Still, the icon is not clickable. What did I miss?
Whoa, the problem was somewhere we're not watching.
I put the DrawerLayout
over the ToolBar
so it was intercepting touch and not let them reach ToolBar
!
The right layout example for the toolbar under the navigation drawert is here as an accepted answer.
Also note:
Just the ActionBarToggle is enough.
You don't need either onOptionsItemSelected()
nor any of these:
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setDisplayShowHomeEnabled(true);
getSupportActionBar().setHomeButtonEnabled(true);