Android menu item background

孤街醉人 提交于 2019-11-30 20:46:15

问题


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!


回答1:


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.




回答2:


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



来源:https://stackoverflow.com/questions/5065828/android-menu-item-background

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!