在 Android 上实现多级选项菜单的最佳实践?
我目前正在将 iPhone 应用程序移植到 Android 上。 iPhone 应用程序在屏幕底部有一个自定义的全局导航菜单,当将其移植到 Android 时,建议将此自定义菜单替换为通用选项菜单(通过设备上的选项键调用)以提供该菜单更原生的 Android 外观和感觉。
问题是菜单本身有多个层(例如,三个主选项,如 A、B、C,以及子选项,如 A1、A2、A3)。我环顾四周,但没有在 Android 应用程序上看到这种多级选项菜单,因此我正在寻找一些关于如何最好地实现这一目标的指南。
我见过一些关于自定义选项菜单的问题,例如这个; Android:自定义应用程序的菜单(例如背景颜色);他们似乎表明本机框架不支持很多选项。
我应该考虑对选项菜单进行一些修改(这是一个好主意吗?),还是考虑其他一些方法来修改应用程序流程?尝试了解在 Android 上保持一致的用户体验,同时减少与 iPhone 应用程序的差异程度的最佳方式。
谢谢!
I'm currently working on a port of an iPhone app into an Android. The iPhone app has a custom global navigation menu at the bottom of the screen, and when bringing this over to Android, it was suggested to replace this custom menu with the generic Option Menu (invoked via the option key on the device) to give it a more native Android look and feel.
The issue is that the menu itself has several layers (e.g. Three main option like A, B, C, and sub-options like A1, A2, A3). I've looked around but have not seen this sort of multi-level option menu on Android apps, so am looking for some guidelines on how this may be best achieved.
I've seen some questions on customizing the Option Menu such as this one; Android: customize application's menu (e.g background color); and they seem to suggest that the native framework doesn't support many options.
Should I be looking at a bit of hacking into the option menu (is this a good idea?), or looking at some other approach to modifying the app flow? Trying to understand what would be the best way to maintain a consistent user experience on Android, while reducing the level of variation from the iPhone app.
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
选项菜单支持子菜单,但只有一层 (即菜单可以有子菜单,但子菜单不能有子菜单)。
Options menus support sub-menus, but only one level deep (i.e., the menu can have a sub-menu, but a sub-menu cannot have a sub-sub-menu).
如果您确实需要(并且想要违反有关菜单深度的 Android 平台标准),那么您可以使用 带有列表的 AlertDialog 用于菜单的每个嵌套级别。从视觉上看,它们看起来与选项菜单完全相同。
If you really need that (and want to violate the Android platform standards regarding menu depth), then you can easily implement this by using an AlertDialog with lists for every nested level of your menu. Visually those appear exactly the same like an options menu.
我做了类似香蕉建议的事情。我只想补充一下限制背后的原因是需要支持的无数设备和屏幕分辨率。多个嵌套菜单在平板电脑上可能看起来不错,但在 5 英寸屏幕上则不然,因此我们需要牢记这一点。
I've done something similar to what banana suggested. I would just add the reasoning behind the limitation is the myriad number or devices and screen resolutions that need to be supported. Multiple nested menus might look good on a tablet but not on a 5 inch screen so we need to keep that in mind.
对我来说,添加
到嵌套菜单项是有效的。
For me, adding
to nested menu items worked.