How to make an overflow menu like in Chrome?

You can’t have custom views for your overflow menu items, so Chrome is not using the standard action bar. It’s weird that Google doesn’t even use its own standard tools that it pushes for everyone else to use, but that’s just how it goes.

If you load up an app that uses the real standard ActionBar (for example, Calendar or Messaging), it’ll have a view in the hierarchy called an ActionBarContainer and you can follow it down all the way to the overflow button, which is an ActionMenuPresenter$OverflowMenuButton.

But load up Chrome in the Hierarchy Viewer, and you’ll find out that what they use for the overflow button is just an ImageButton.

Obviously you can either make your own full-on ActionBar implementation, or add an overflow button to the existing ActionBar and somehow make sure the real overflow button never gets displayed. You might find the ActionBar compatibility sample project useful in making a fake actionbar. Either way, if you again look in the Hierarchy Viewer, they’re just using a PopupMenu to display the menus in both the real ActionBar apps and the Chrome app.

Hopefully that helps enough to get you started.

Leave a Comment