To change the colors of overflow list elements, add two elements to the application theme, which are usually defined in res/values/styles.xml :
<item name="android:dropDownListViewStyle">@style/DropDownListView</item> <item name="dropDownListViewStyle">@style/DropDownListView</item>
In the same file, add the style you just assigned:
<style name="DropDownListView" parent="@style/Widget.Sherlock.ListView.DropDown"> <item name="android:listSelector">@drawable/selectable_background</item> </style>
And finally, create a drawable selectable_background.xml selector in the drop-down folder containing the following:
<selector xmlns:android="http://schemas.android.com/apk/res/android" android:exitFadeDuration="@android:integer/config_mediumAnimTime" > <item android:state_pressed="false" android:state_focused="true" android:drawable="@color/focussed_color" /> <item android:state_pressed="true" android:drawable="@color/pressed_color" /> <item android:drawable="@android:color/transparent" /> </selector>
Finally, define the colors that usually fit in colors.xml :
<resources> <color name="pressed_color">#FF8E4067</color> <color name="focussed_color">#DD8E4067</color> </resources>
In my application, I used the "ActionBar Style Generator" as the proposed baboo, which handles everything for you conveniently. For this answer, I simply extracted and simplified the parts that, in my opinion, make up the overflow menu style.
I think there is some secret about the stylization effects of three different objects:
- In my opinion,
android:dropDownListViewStyle includes an overflow menu that hides behind the “three dots” in the ActionBar. - Not to be confused with
android:actionDropDownStyle , which is used to style the application’s drop-down list if you used actionBar.setNavigationMode(NAVIGATION_MODE_LIST) - However, some Android devices with a hardware menu button (for example, Nexus S or Galaxy S3 Mini) do not display the “three dots”, but the overlay menu, which is at the bottom of the screen if the hardware menu button is pressed.
android:popupMenuStyle is the right attribute for the style.
Again, this is only as far as I remember from my own application development.
Also, make sure that other style files (for example, folders with configuration qualifiers ) overwrite the styles you just created.
In general, I understand that this will only change the background color of the list items. To use a completely non-standard view, you can create a custom counter view , add a dummy button with the "three dots" icon to your ActionBar and open the counter, click the button.