I'm trying to change the background color of a popup menu in the actionbar, when using Android Support Library v7. I've been trying various suggested solutions that I've found, but none of them have worked, the popup menu background simply doesn't change from the theme's standard color. This is what I've done so far:
AndroidManifest:
android:theme="@style/MyTheme" >
values/themes.xml:
<resources xmlns:android="http://schemas.android.com/apk/res/android">
<style name="MyTheme" parent="@style/Theme.AppCompat">
<item name="popupMenuStyle">@style/MyPopupMenu</item>
</style>
<style name="MyPopupMenu" parent="@style/Widget.AppCompat.PopupMenu">
<item name="background">#ffffff</item>
</style>
</resources>
The values-11 and values-14 folders also have a theme file each, with the difference that the popupMenuStyle and background attributes are instead written as android:popupMenuStyle and android:background, since they aren't supposed to use the support library.
Thanks in advance.
Open the colors. xml file by navigating to the app -> res -> values -> colors. xml. Create a color tag inside the resources tag with a name and set a color with its hex code.
Which option of the pop up menu should we click to change the wallpaper? On the Themes tab, under Theme Options, click Background. On the pop-up menu, click Format Background.
Go to app > res > right-click > New > Android Resource Directory and give Directory name and Resource type as menu. Now, we will create a popup_menu file inside that menu resource directory. Go to app > res > menu > right-click > New > Menu Resource File and create a menu resource file and name it as popup_menu.
in your style.xml add popupMenuStyle like this:
<style name="Theme.MyTheme" parent="Theme.AppCompat.Light.DarkActionBar">
...
<item name="popupMenuStyle">@style/popupMenuStyle</item>
</style>
<style name="popupMenuStyle" parent="@android:style/Widget.PopupMenu">
<item name="android:popupBackground">@color/white</item>
</style>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With