Change background popupMenu in Android

user1854307 picture user1854307 · Mar 11, 2014 · Viewed 23.6k times · Source

I tried to change background of popupmenu, but my implementation does not work.

This is my code:

<style name="MyHoloLight" parent="android:Theme.Holo.Light">
    <item name="android:popupMenuStyle">@style/popupMenuStyle</item>
</style>
<style name="popupMenuStyle" parent="@android:style/Widget.PopupMenu">
    <item name="android:popupBackground">@color/bgPopumMenu</item>
</style>

Apply in AndroidManifest.xml

<application
        android:hardwareAccelerated="true"
        android:label="@string/app_name"
        android:icon="@drawable/ic_launcher"
        android:theme="@style/MyHoloLight">

Answer

Raju picture Raju · Oct 13, 2016

the following styles working perfectly for me.

<style name="popupMenuStyle" parent="Theme.AppCompat.Light.DarkActionBar">
    <item name="android:textColor">@color/color_white</item>
    <item name="android:itemBackground">@color/color_red</item>
</style>

here, parent should be the AppTheme parent

and in your code use these lines.

Context wrapper = new ContextThemeWrapper(context, R.style.popupMenuStyle);
PopupMenu popup = new PopupMenu(wrapper, v);

i hope it will work.