Changing background color and text color of the overflow menu

15,342 views
Skip to first unread message

Davy De Waele

unread,
Jun 7, 2012, 9:57:15 AM6/7/12
to actionba...@googlegroups.com
Hi,

I'm trying to change the background color and text color of the overflow menu with limited success.

I'm styling my action bar like this :
    <style name="Theme.MyTheme4" parent="Theme.Sherlock.ForceOverflow">
    <item name="actionBarStyle">@style/Widget.MyTheme3.ActionBar</item>
    <item name="android:actionBarStyle">@style/Widget.MyTheme3.ActionBar</item>
<item name="android:dropDownListViewStyle">@style/Theme.MyTheme4.ListView.DropDown</item>
    <item name="dropDownListViewStyle">@style/Theme.MyTheme4.ListView.DropDown</item>
    </style>
The actionBarStyle is used to set a background on the actionbar, and that works fine.

Overflow menu background

The dropDownListViewStyle is used to set a background on the overflow menu, and that also works fine on all my devices EXCEPT in the Android 4.0.3 emulator.
I don't have an actual Android 4.0.3 device so I wonder if the background will be set correctly on such a device, or if this is just an emulator issue (like the fact  that the overflow 3-button icon is never shown).
 
The background is being set correctly on an actual Android 4.0.4 device. (and also on Android 2.x devices).
 
Overflow menu text color

I've tried many things, but I'm unable to change the text color of the actual overflow menu items. I've only managed to set them to either black or white by changing the parent theme (Theme.Sherlock.ForceOverflow for white text, Theme.Sherlock.Light.ForceOverflow for black text).

How can I set the text color of the overflow menu item to a different color ? There was an earlier thread here discussing the same thing but no final solution was provided.

Thanks in advance...

Jake Wharton

unread,
Jul 6, 2012, 3:51:15 AM7/6/12
to actionba...@googlegroups.com
The overflow background can be changed by defining a popupMenuStyle attribute in the theme. You should extend from Widget.Sherlock.PopupMenu in your own style where you can change the android:background attribute.

---
Jake Wharton
http://about.me/jakewharton

Nikolay Ivanets

unread,
Sep 6, 2012, 5:38:55 AM9/6/12
to actionba...@googlegroups.com
What about " Overflow menu text color"?

Nikolay Ivanets

unread,
Sep 6, 2012, 7:13:34 AM9/6/12
to actionba...@googlegroups.com
Finally, I found an answer. However, I didn't test impact on other widgets on ActionBar:

<style name="MyTheme" parent="Theme.Sherlock.ForceOverflow">
<item name="android:actionBarWidgetTheme">@style/MyActionWidgetTheme</item>
<item name="actionBarWidgetTheme">@style/MyActionWidgetTheme</item>
</style>

<style name="MyActionWidgetTheme" parent="Widget">
<item name="android:textColor">#f00</item>
</style>

Ashok chakravarthi

unread,
Sep 14, 2014, 7:22:40 AM9/14/14
to actionba...@googlegroups.com
Kudos...   This saves my day... Thanks a lot.

Varun Sharma

unread,
Dec 2, 2014, 12:48:26 AM12/2/14
to actionba...@googlegroups.com
actionbaeWidgetTheme was working fine till Android L came. Now using this property i am not able to change the text color of overflow menu. Has anyone else also faced the same problem?


On Thursday, September 6, 2012 4:43:34 PM UTC+5:30, Nikolay Ivanets wrote:
Reply all
Reply to author
Forward
0 new messages