开发者

Android menu item background

开发者 https://www.devze.com 2023-02-12 03:20 出处:网络
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 w

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 开发者_如何学Pythonback 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)

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号