The type of resource that PopupMenu expects as Background is an image, more exactly a 9-Patch bitmap , not a Color .
After creating the 9-Patch bitmap you want to use put it in the res\drawable
folder. You should preferably create one for each screen density.
Declare a style in the file
values\styles.xml
and assign the bitmap to
popupBackground
.
<style name="PopupMenu.Laranja" parent="@style/Widget.AppCompat.Light.PopupMenu">
<item name="android:popupBackground">@drawable/menu_dropdown_panel_background</item>
</style>
In style for the theme of the application, indicate that PopupMenu should use this new style .
<item name="popupMenuStyle">@style/PopupMenu.Laranja</item>
The file values\styles.xml
looks like this:
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
<!-- Style que o popupMenu deve utilizar -->
<item name="popupMenuStyle">@style/PopupMenu.Laranja</item>
</style>
<!-- Style do popupMenu. -->
<style name="PopupMenu.Laranja" parent="@style/Widget.AppCompat.Light.PopupMenu">
<item name="android:popupBackground">@drawable/popup_menu_background</item>
</style>
</resources>
To test use this 9-Patch bitmap :
Give it the name popup_menu_background.9.png and put it in the res\drawable
folder.