Skip to content

Instantly share code, notes, and snippets.

@kbshl
Created November 25, 2016 15:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kbshl/1feb7a1eddfa62e73f85ef22ed057e78 to your computer and use it in GitHub Desktop.
Save kbshl/1feb7a1eddfa62e73f85ef22ed057e78 to your computer and use it in GitHub Desktop.
Change the behavior of the hardware menu button when it is present to show/hide the toolbar overflow menu - From http://stackoverflow.com/questions/27362030/toolbar-overflow-menu-button-always-showing
@Override
public boolean onKeyUp(int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_MENU) {
if (mToolbar.isOverflowMenuShowing()) {
mToolbar.hideOverflowMenu();
}
else {
mToolbar.showOverflowMenu();
}
return true;
}
return super.onKeyUp(keyCode, event);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment