Search code examples
androidandroid-actionbar

How to force use of overflow menu on devices with menu button


I'd like to have all of the menu items that don't fit into the ActionBar go into the overflow menu (the one that is reached from the Action Bar not the menu button) even on devices that do have a Menu button. This seems much more intuitive for users than throwing them into a separate menu list that requires the user to jump from a touch(screen) interaction to a button based interaction simply because the layout of the ActionBar can't fit them on the bar.

On the emulator I can set the "Hardware Back/Home Keys" value to "no" and get this effect. I've searched for a way to do this in code for an actual device that has a menu button but can't fine one. Can anyone help me?


Solution

  • EDIT: Modified to answer for the situation of physical menu button.

    This is actually prevented by design. According to the Compatibility Section of the Android Design Guide,

    "...the action overflow is available from the menu hardware key. The resulting actions popup... is displayed at the bottom of the screen."

    You'll note in the screenshots, phones with a physical menu button don't have an overflow menu in the ActionBar. This avoids ambiguity for the user, essentially having two buttons available to open the exact same menu.

    To address the issue of consistency across devices: Ultimately it's more important to the user experience that your app behave consistently with every other app on the same device, than that it behave consistently with itself across all devices.