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!
Asked
Active
Viewed 1.3k times
2 Answers
5
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.

Pilot_51
- 7,337
- 3
- 29
- 26
-
This is the correct way to do it. Using themes/styles & doing the most of customization in XMLs. You can get the attribute here : [panelColorBackground](http://developer.android.com/reference/android/R.attr.html#panelColorBackground) A good integration example comes directly from the sources. Check out [themes on devdaily.com](http://www.devdaily.com/java/jwarehouse/android-examples/platforms/android-7/data/res/values/themes.xml.shtml) and [styles](http://www.devdaily.com/java/jwarehouse/android-examples/platforms/android-7/data/res/values/styles.xml.shtml) – MrBuBBLs Nov 29 '11 at 14:55
-
1@Pilot_51, hi, where should I apply the panelFullBackground style? I tried to apply it on menu, theme, and menu item, none of them worked – fifth Sep 23 '14 at 05:01
1
try to use android own menu icon like as setIcon(android.R.drawable.ic_menu_search)

Niranj Patel
- 32,980
- 10
- 97
- 133