如何制作像 Chrome 一样的溢出菜单? [英] How to make an overflow menu like in Chrome?

查看:31
本文介绍了如何制作像 Chrome 一样的溢出菜单?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想制作一个类似于 android 中的 chrome 应用程序的溢出菜单,其中包含前进、后退和书签按钮.这是 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.

有什么想法吗?

推荐答案

您无法为溢出菜单项设置自定义视图,因此 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.

如果您加载使用真正标准 ActionBar(例如,日历或消息)的应用程序,它将在层次结构中具有一个名为 ActionBarContainer 你可以一直到溢出按钮,这是一个 ActionMenuPresenter$OverflowMenuButton.

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.

但是在 Hierarchy Viewer 中加载 Chrome,您会发现它们用于溢出按钮的只是一个 ImageButton.

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.

显然,您可以制作自己的完整 ActionBar 实现,也可以向现有 ActionBar 添加一个溢出按钮,并以某种方式确保真正的溢出按钮永远不会显示.您可能会发现 ActionBar 兼容性示例项目在制作假操作栏时很有用.无论哪种方式,如果您再次查看层次结构查看器,他们只是使用 PopupMenu 在真正的 ActionBar 应用程序和 Chrome 应用程序中显示菜单.

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.

这篇关于如何制作像 Chrome 一样的溢出菜单?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆