I\'d like to change the background color of the option (overflow) menu in Android 4.2. I have tried all the methods but it is still showing the default color set by the them
FAST way!
styles.xml
<style name="popupTheme" parent="Theme.AppCompat.Light">
<item name="android:background">@color/colorBackground</item>
<item name="android:textColor">@color/colorItem</item>
</style>
Then add this specific styles to your AppTheme styles
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
...
<item name="popupTheme">@style/popupTheme</item>
</style>
DONE!
Add following to your Styles.xml
<style name="Custom_Theme" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="android:itemBackground">@color/white</item>
<item name="android:textColor">@color/colorPrimaryDark</item>
</style>
Change theme in activity_main.xml
only.
android:theme="@style/Custom_Theme"
To alter the color of the app bar only, you just have to change the colorPrimary value inside the colors.xml file and the colorPrimaryDark if you want to change the battery bar color as well:
<resources>
<color name="colorPrimary">#B90C0C</color>
<color name="colorPrimaryDark">#B90C0C</color>
<color name="colorAccent">#D81B60</color>
</resources>
I'm also struck with this same problem, finally i got simple solution. just added one line to action bar style.
<style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar">
<item name="android:textColorPrimary">@color/colorAccent</item>
<item name="android:colorBackground">@color/colorAppWhite</item>
</style>
"android:colorBackground" is enough to change option menu background
In case you are working in the latest toolbar in android studio then here is the smallest solution To change the toolbar options menu color, add this to your toolbar element
app:popupTheme="@style/MyDarkToolbarStyle"
Then in your styles.xml define the popup menu style
<style name="MyDarkToolbarStyle" parent="ThemeOverlay.AppCompat.Light">
<item name="android:colorBackground">@color/mtrl_white_100</item>
<item name="android:textColor">@color/mtrl_light_blue_900</item>
</style>
Note that you need to use colorBackground not background. The latter would be applied to everything (the menu itself and each menu item), the former applies only to the popup menu.