How to style text in action overflow menu on device with Android>4.0 and hardware button?

David Vávra picture David Vávra · Jan 7, 2013 · Viewed 14.3k times · Source

I would like custom background & text color for my overflow menu. It works fine with devices without hardware menu button, but I'm not able to style devices with hardware menu button. See the screenshots:

Screnshot from Galaxy Nexus Screenshot from Galaxy S3

I'm using these styles:

<style name="Theme.settleup" parent="@style/Theme.Sherlock.Light.DarkActionBar">
    <item name="android:popupMenuStyle">@style/settleup_PopupMenu</item> 
    <item name="android:actionMenuTextColor">@android:color/white</item>
</style>
<style name="settleup_PopupMenu" parent="@style/Widget.Sherlock.ListPopupWindow">
    <item name="android:popupBackground">@drawable/menu_dropdown_panel_settleup</item>
</style>

Answer

Tomik picture Tomik · Jan 23, 2013

I've looked into the problem. And there seems to be no way in changing textColor for the options menu for Android >= 4.0 devices with HW menu key. Not even changing primary, secondary or tertiary colors affected the text color.
The only "solution" that comes to my mind now is some pretty nasty use of java reflection API.

However, you can set the background of the bottom options menu of Android >= 4.0 HW key devices separately from the background of the non-HW key dropdown menu.

You already has the styling for non-HW key dropdown menu. The non-HW key dropdown menu is defined by android:popupMenuStyle (and popupMenuStyle):

<style name="Theme.settleup" parent="@style/Theme.Sherlock.Light.DarkActionBar">
    <item name="android:popupMenuStyle">@style/settleup_PopupMenu</item> 
</style>

But the background of the Android >= 4.0 HW key bottom options menu is defined with android:panelBackground item in the theme:

<style name="Theme.settleup" parent="@style/Theme.Sherlock.Light.DarkActionBar">
    <item name="android:panelBackground">@drawable/mybackground</item>
</style>

Since it seems to be a problem to change the text color for bottom options menu on Android >= 4.0 HW key devices, I would suggest to leave this part to its default styling.