Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make an overflow menu like in Chrome?

I would like to make an overflow menu similar to the chrome app in android in which it has the forward, backward and bookmark buttons inside it. This is the overflow menu in the chrome app.

Any ideas?

like image 826
Angel Solis Avatar asked Nov 06 '12 21:11

Angel Solis


People also ask

Where is the overflow menu in Chrome?

For clarity, that's the menu tucked behind the three-dot icon at the top-right-hand side of Chrome.

How do I add an overflow button?

The Android overflow menu is accessed from the far right of the actions toolbar at the top of the display of the running app. This menu provides a location for applications to provide additional options to the user.

What is overflow icon in Chrome?

Google Chrome has got a new tab overflow indicator in the Canary branch. It makes it easy to spot that you have more tabs than are currently visible, and you need to scroll the tab row to see the rest of them. Here's how it looks.

Where is the overflow button?

The action overflow in the action bar provides access to your app's less frequently used actions. The overflow icon only appears on phones that have no menu hardware keys. Phones with menu keys display the action overflow when the user presses the key. Action overflow is pinned to the right side.


1 Answers

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.

like image 198
ajpolt Avatar answered Oct 07 '22 10:10

ajpolt