I created an action bar with ActionBarSherlock. I want to stylize the action bar, so when I click on the menuitem element (the drop-down element that appears from the overflow), the background of the menuitem should change color. (Now it changes to blue by default, I want it to be a different color).
After a lot of googleing and testing, I came up with the following:
themes.xml :
<style name="AppTheme" parent="Holo.Theme"> <item name="android:popupMenuStyle">@style/PopupMenuStyle</item> <item name="popupMenuStyle">@style/PopupMenuStyle</item> </style> <style name="PopupMenuStyle" parent="@style/Widget.Sherlock.PopupMenu"> <item name="android:dropDownSelector">@drawable/menu_selector</item> </style>
menu_selector.xml : (e.g. abs__list_selector_holo_dark.xml )
<?xml version="1.0" encoding="utf-8"?> <selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:state_window_focused="false" android:drawable="@android:color/transparent" /> <item android:state_focused="true" android:state_enabled="false" android:state_pressed="true" android:drawable="@drawable/abs__list_selector_disabled_holo_dark" /> <item android:state_focused="true" android:state_enabled="false" android:drawable="@drawable/abs__list_selector_disabled_holo_dark" /> <item android:state_focused="true" android:state_pressed="true" android:drawable="@color/AppRed" /> <item android:state_focused="false" android:state_pressed="true" android:drawable="@color/AppRed" /> <item android:state_focused="true" android:drawable="@drawable/abs__list_focused_holo" /> <item android:drawable="@color/AppRed" /> </selector>
Unfortunately, the background is still changing to blue, not red. What am I missing here?
source share