简体   繁体   中英

Android menu item background

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 (eg @android:color/black or @drawable/my_drawable ), it will crash if you use a color value directly.

尝试使用像setIcon(android.R.drawable.ic_menu_search)这样的android自己的菜单图标

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM