如何在android actionbar compat上强制溢出菜单? [英] How to force overflow menu on android actionbar compat?

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

问题描述

Android 操作栏兼容
是否可以?在旧设备(3.0 之前)上,不适合操作栏的项目仅在按下菜单键时显示,我希望将这些项目分组到操作栏的溢出菜单中.

Android action bar compat
Is it possible? On older devices (pre 3.0) the items that don't fit the action bar are only shown when the menu key is pressed, I want these items to be grouped in the actionbar's overflow menu.

推荐答案

动作溢出菜单仅在设备上没有可用的硬菜单按钮时可用.我在用户界面 > 操作栏下的框架主题中发现了这一点,请查看第 3 个项目符号 这里.

The action overflow menu is only available when there is no hard menu button available on the device. I found this stated in the Framework Topics under User Interface > Action Bar, check out the 3rd bullet here.

有一个由 Jake Wharton 编写的操作栏库,名为 ActionBarSherlock.也许即使在较旧的设备上(包括硬菜单按钮),这也可以为您提供操作溢出菜单样式,但是我没有研究过这个.

There is an action bar library written by Jake Wharton called ActionBarSherlock. Perhaps this is able to supply you with an action overflow menu style even when on older devices (which include a hard menu button), however I have not looked into this.

ActionBarSherlock 4.0(目前是一个候选版本)具有内置的功能来强制操作溢出.如果您想自己扩展 ActionBarCompat 示例,您可以查看 github 以了解 Jake 如何实现它.我建议考虑一起使用他的图书馆,因为它做得很好.

ActionBarSherlock 4.0 (currently a release candidate) has functionality built in to force action overflow. If you want to extend the ActionBarCompat example yourself, you could take a look on github to get an idea how Jake implemented it. I would suggest just looking into using his library all together, as it is very well done.

如果您选择使用 Jake 的库,请考虑将 Activity 主题设置为 @style/Theme.Sherlock.ForceOverflow 以在旧设备上强制使用溢出菜单.

If you choose to use Jake's library, look into setting up the Activity theme as @style/Theme.Sherlock.ForceOverflow to force the overflow menu on older devices.

Edit2: 使用 ForceOverflow 主题会导致问题 (示例 #1) 在带有硬件菜单按钮的设备上.因此,Jake Wharton 将在未来的版本中移除 ForceOverflow.

Using ForceOverflow theme causes issues (example #1) on devices with hardware menu button. Thus, Jake Wharton is going to remove ForceOverflow in the future versions.

这篇关于如何在android actionbar compat上强制溢出菜单?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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