Home » Android » android – Overriding ActionBarCompat overflow pop-up background?

android – Overriding ActionBarCompat overflow pop-up background?

Posted by: admin June 15, 2020 Leave a comment

Questions:

I am using actionbarcompat for my android project and using @style/Theme.AppCompat.Light.DarkActionBar as my base Theme.The overflow menu in this action bar has a black background by default which I want to change to white color.I know this can be done overdding the popup widget with property popupBackground but its not working in my case.My styles file has following code:

<style name="MyTheme" parent="@style/Theme.AppCompat.Light.DarkActionBar">
        <item name="android:actionBarStyle">@style/MyActionBar</item>
        <item name="android:actionDropDownStyle">@style/MyActionBarDropDown</item>
         <item name="android:popupMenuStyle">@style/PopupMenu</item>
</style>

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

But the above code is not running as its giving me Error: No resource found that matches the given name: attr ‘popupBackground’.SomeOne please help me to correct above code.

How to&Answers:

Just remove ->

<item name="popupBackground">@drawable/menu_dropdown_panel_example</item>

Put it like this ->

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