The type of Resource that Popupmenu expects how Background is an image, more exactly a 9-Patch bitmap, and not a Color.
After creating the 9-Patch bitmap you want to use put it in the folder res\drawable
. You should preferably create one for each screen density.
Declare a style in the archive values\styles.xml
and attribute the bitmap at the popupBackground
.
<style name="PopupMenu.Laranja" parent="@style/Widget.AppCompat.Light.PopupMenu">
<item name="android:popupBackground">@drawable/menu_dropdown_panel_background</item>
</style>
In the style concerning the Theme of the application indicates that the Popupmenu shall use that new style.
<item name="popupMenuStyle">@style/PopupMenu.Laranja</item>
The archive values\styles.xml
will look 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 briefcase res\drawable
.
It worked perfectly! Abusing a little of your good will, where I get a png of that in white color. I tried to change the orange png in Fireworks but it was not good.
– Edson Santos
A quick way is to go here. Change the color of Popup color to white. Do the download of ZIP and use the file menu_dropdown_panel.9.png which is in the folders for different densities.
– ramaral