Search code examples
androidstylespopupmenu

Android: how to change background color in popupmenu


I'm trying to change the color of PopMenu that is displayed by a onlongclick method. I used the following style but had no effect, are there any suggestions on how I can change the style of PopMenu? The style was declared in AndroidManifest.xml

<style name="NewStyle" parent="android:Theme.NoTitleBar.Fullscreen">
    <item name="android:popupMenuStyle">@style/PoppupMenu</item>
</style>

<style name="PoppupMenu" parent="android:Widget.PopupMenu">
    <item name="android:popupBackground">@drawable/corazul</item>
</style>

Solution

  • I solved the problem using this code:

    Context wrapper = new ContextThemeWrapper(getContext(), R.style.PopupMenu);
    PopupMenu popupMenu = new PopupMenu(wrapper, v);
    

    reference: blog.stylingandroid.com