如何强制行动吧溢图标以显示 [英] How to force action bar overflow icon to show

查看:101
本文介绍了如何强制行动吧溢图标以显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想迫使溢图标总是在操作栏中显示(假设存在溢出项)。在一个菜单按钮的机型,有时溢图标没有出现,用户必须挖掘设备的菜单按钮,让操作菜单项的其余部分。用户一直抱怨这一点。

I would like to force the overflow icon to always show in the action bar (assuming there are overflow items). On models with a menu button, sometimes the overflow icon doesn't appear and users must tap the devices menu button to get the rest of the action menu items. Users keep complaining about this.

请注意,对于上下文菜单,溢图标总是显示,无论设备是否有一个内置的菜单按钮,或没有。

Note that for the context menu, the overflow icon always shows, regardless of whether the device has a built in menu button or not.

我认识到,迫使溢图标显示在操作栏将重复的物理的一个功能。你可能会认为违反了机器人的设计准则。在我看来,虽然,赢得用户。他们说这是混乱的,我相信他们是对的。

I realize that forcing the overflow icon to appear in the action bar would duplicate the functionality of the "physical" one. You might consider that violating Androids design guidelines. In my opinion, though, the users win. They say it's confusing and I believe they're right.

推荐答案

恭喜!你赢了!

由于Android 4.4系统后,...启示操作栏中会在那里,无论设备是否有身体MENU按钮或没有。现在,谷歌目前的兼容性定义文档出来一点更有力地反对有一个专用的MENU按钮。

As of Android 4.4, the ... affordance in the action bar will be there, regardless of whether the device has a physical MENU button or not. Google's current Compatibility Definition Document now comes out a bit more forcefully against having a dedicated MENU button.

这是开发人员在过去使用,来获得这一行为的黑​​客是:

The hack that developers have used in the past, to get this behavior, is:

try {
  ViewConfiguration config = ViewConfiguration.get(this);
  Field menuKeyField = ViewConfiguration.class.getDeclaredField("sHasPermanentMenuKey");

  if (menuKeyField != null) {
    menuKeyField.setAccessible(true);
    menuKeyField.setBoolean(config, false);
  }
}
catch (Exception e) {
  // presumably, not relevant
}

这应该没有必要在Android 4.4+,虽然在地方的异常处理程序,我不希望任何特别的问题,如果你运行它,并,有一天,他们摆脱 sHasPermanentMenuKey 顾左右而言他。

That should not be needed on Android 4.4+, though with the exception handler in place, I would not expect any particular problem if you run it and, someday, they get rid of sHasPermanentMenuKey outright.

就个人而言,我仍然不会改变的东西在Android 4.3及以下的,我怀疑这是一个失衡一个痣的情况,在那里你将取代大鱼大肉关于有相同的菜单重复版本的投诉没有菜单投诉。话虽这么说,因为这是目前正式批准的行为顺利进行,我没有任何问题与开发商瞄准了一致性的旧设备。

Personally, I still wouldn't change things on Android 4.3 and below, as I suspect it's a whack-a-mole situation, where you will replace complaints about having no menu with complaints about having duplicate versions of the same menu. That being said, since this is now the officially endorsed behavior going forward, I have no problems with developers aiming for consistency on older devices.

一个帽尖到对我提起对此,指出了变化。

A hat tip to the commenter on the issue I filed regarding this, pointing out the change.

这篇关于如何强制行动吧溢图标以显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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