How to make overflow menu like Chrome app?

谁说我不能喝 提交于 2019-12-28 06:35:22

问题


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

Any ideas? Please i need help.

Thanks in advance.


回答1:


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.




回答2:


Have a look to Android ActionBar for the whole component.

For the sole layout, you can inflate any layout and place it anywhere you want...



来源:https://stackoverflow.com/questions/13259995/how-to-make-overflow-menu-like-chrome-app

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!