安卓菜单项目背景[英] Android menu item background

本文是小编为大家收集整理的关于安卓菜单项目背景的处理/解决方法,可以参考本文帮助大家快速定位并解决问题,中文翻译不准确的可切换到English标签页查看源文。

问题描述

我想改变菜单项背景beacuse我使用黑色图标,但在一些手机上,背景的默认颜色是黑色或其他暗颜色.我尝试了这个解决方案,它的工作,但它有一点赋予它: 我有十个项目,这就是为什么我有一个"更多"项目来显示其他选项,但如果我选择更多的项目(这是自定义背景)并且在我按下返回按钮之后,该项目将处于默认状态,默认颜色.解决办法是什么?谢谢!

推荐答案

菜单背景的样式属性是android:panelFullBackground.它并不像其他解决方案一样乱砍,所以它不是像越野车一样.

尽管文档所说,它需要是资源(例如@android:color/black或@drawable/my_drawable),如果直接使用颜色值,则会崩溃.

其他推荐答案

尝试使用Android自己的菜单图标如seticon(android.r.drawable.ic_menu_search)

本文地址:https://www.itbaoku.cn/post/102723.html

问题描述

I want to change the menu item background beacuse I use black icons, but on some phones the default color of background is black or other dark color. I tried this solution and it's worked but there was a little problen with it: I have ten items and that's why I have a "More" item to show other options, but if I choose the More item (which is got the custom background) and after that I press back button, the item will be in the default state, default colors. What is the solution? Thanks!

推荐答案

The style attribute for the menu background is android:panelFullBackground. It's not hackish like the other solution, so it's not as buggy.

Despite what the documentation says, it needs to be a resource (e.g. @android:color/black or @drawable/my_drawable), it will crash if you use a color value directly.

其他推荐答案

try to use android own menu icon like as setIcon(android.R.drawable.ic_menu_search)