Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Light.DarkActionBar menu item text colour unchangeable?

Tags:

The application I've been developing uses ActionBarSherlock, and the main theme inherits from Theme.Sherlock.Light.DarkActionBar. The design requires that the overflow menu popups have a dark coloured background and white text. This works fine for devices without a physical menu button, and the text appears white as intended. However, if the device DOES have a physical menu button, the text shown in the menu displayed remains black.

My main theme contains

<item name="android:panelBackground">@drawable/menu_hardkey_panel</item>

...Where @drawable/menu_hardkey_panel is a dark coloured 9patch.

The resulting appearance of the menu popup is... Light.DarkActionbar issue

I'm unable to determine why this is happening, or how to manually change the colour of the text. In my main theme, I've tried all of the following...

<item name="android:actionMenuTextColor">@android:color/white</item>
<item name="android:textAppearanceLargePopupMenu">@style/MyMenuTextAppearance.Large</item>
<item name="android:textAppearanceSmallPopupMenu">@style/MyMenuTextAppearance.Small</item>

I've even tried

<item name="android:actionBarWidgetTheme">@style/Theme.MyApp.Dark</item>

...Where Theme.MyApp.Dark is...

<style name="Theme.MyApp.Dark" parent="@style/Theme.Sherlock">
    <item name="android:dropDownListViewStyle">@style/DropDownListView</item>
    <item name="dropDownListViewStyle">@style/DropDownListView</item>
</style>

None have let me change the text to white. If I make my base theme inherit from Theme.Sherlock, the problem is solved and the text is white, but unfortunately that's not an option.

like image 396
Chris Horner Avatar asked Nov 12 '12 08:11

Chris Horner


2 Answers

Not entirely sure about this, but I believe the pop-up menu uses the same styling as the overflow menu. In which case you'd just do something like this.

<item name="android:itemTextAppearance">@style/your_new_text_appearance</item>

<style name="your_new_text_appearance">
    <item name="android:textColor">@android:color/white</item>
</style>
like image 190
Jay Soyer Avatar answered Sep 24 '22 00:09

Jay Soyer


Giving it a chance: there is a text appearance called actionMenuTextAppearance. Have you tried that?

Update: I did some more digging and I believe that this file is the layout And there they refer to textAppearanceListItemSmall and textAppearanceSmall. However, it takes this value from a special theme which is specified as following in Theme.Holo.Light

<item name="panelMenuListTheme">@android:style/Theme.Holo.Light.CompactMenu</item>

And like this in Theme.Holo:

<item name="panelMenuListTheme">@android:style/Theme.Holo.CompactMenu</item>

The problems comes from the fact that the parent of Sherlock.__Theme.DarkActionBar is Theme.Sherlock.Light. This is not valid for the dark action bar. Taking the line from Theme.Holo should do the trick.

like image 30
Tobias Ritzau Avatar answered Sep 23 '22 00:09

Tobias Ritzau