I'm trying to allow the user to open/close the navigation drawer in my app by tapping the action bar title (this is how the current Android Gmail app is set up). At the moment, the user can toggle the drawer by tapping the app/drawer icon or by sliding it in with a left-right swipe. However, the action bar title itself is not clickable. According to the developer docs, clicking the action bar title should "dispatch onOptionsItemSelected
to the host Activity with a MenuItem with item ID android.R.id.home
" when we use NAVIGATION_MODE_STANDARD
but for some reason I can't get the title to behave this way.
I believe the Navigation Drawer itself is fine, but here is how I set up the Action Bar:
private void configureActionBar(CharSequence mTitle) {
ActionBar actionBar = getActionBar();
actionBar.setDisplayHomeAsUpEnabled(true);
actionBar.setHomeButtonEnabled(true);
actionBar.setIcon(R.drawable.ic_blank);
GradientDrawable gd = new GradientDrawable(GradientDrawable.Orientation.TOP_BOTTOM,
new int[] {
0xFF004700, 0xFF002900
});
gd.setCornerRadius(0f);
actionBar.setBackgroundDrawable(gd);
// set the title of the action bar using the given title
actionBar.setTitle(mTitle);
}
Any suggestions would be greatly appreciated!