Reputation: 1201
I am using android compact library for building the action bar for both older and newer versions of android. so my requirement includes that i need to show action bar in blue color. now i have changed the action bar background color to blue , now i want to change the background color of popup menu which comes when we click on overflow icon. I tried in many ways but nothing is changing the background color.any one suggest me whether we can change the background color of popup menu using app-compact library or not, if we can please suggest me
Upvotes: 0
Views: 3973
Reputation: 3215
Add this to your toolbar element
app:popupTheme="@style/ThemeOverlay.YourApp"
Then in your styles.xml
define the popup menu style
<style name="ThemeOverlay.YourApp" parent="ThemeOverlay.AppCompat.Light">
<item name="android:colorBackground">@color/your_background_color</item>
<item name="android:textColor">@color/your_text_color</item>
</style>
Note that you need to use colorBackground
and never background
. The latter would be applied to everything (the menu itself and each menu item), the former applies only to the popup menu.
Source: Style appcompat-v7 Toolbar menu background
Upvotes: 5
Reputation: 82938
Use android:popupBackground
into styles.
like
<style name ="MyPopupMenu" parent="Theme.AppCompat.Light">
<item name="popupMenuStyle">@style/MyPopupMenuStyle</item>
</style>
<style name="MyPopupMenuStyle">
<item name="android:dropDownSelector">@drawable/abc_list_selector_holo_dark</item>
<item name="android:popupBackground">@drawable/abc_menu_dropdown_panel_holo_dark</item>
<item name="android:dropDownVerticalOffset">0dip</item>
<item name="android:dropDownHorizontalOffset">0dip</item>
<item name="android:dropDownWidth">wrap_content</item>
</style>
Upvotes: 1