更新时间:2023-12-04 09:56:28
遗憾的是 PopupMenu
默认不支持图标.
Unfortunately PopupMenu
does not support icons by default.
替代方法包括创建您自己的扩展PopupMenu
的类或更简单的切换到使用 ActionBar
.带有图标的Android兼容性弹出菜单有一个GitHub存储库,这可能会有所帮助.
Alternatives include creating your own class which extends PopupMenu
or more simply switching to using an ActionBar
. There is a GitHub repository for an Android Compatibility popup menu with icons, which might be helpful.
在这三个选项中,我建议使用 ActionBar
,因为 android 似乎大力推动使用 ActionBar
作为***实践,而不是其传统标题菜单指南.
Of the three options I would suggest going with the ActionBar
because android seem to be heavily pushing the use of the ActionBar
as best practice over the traditional header menus in their guides.
我希望这会有所帮助.