11

I'm facing an issue on devices with a separate menu key (like the Samsung onces). In some Activities the textcolor of the Overflow Menu Items is white when opened via the Menu-Key. Opening the Overflow via the three dots the textcolor is always black - like it should be.

Following a Screenshot which visualizes the issue. On the left side the everything is fine, overflow has been opened via the three dots. On the right side the menu has been opened via the Menu-Key:

picture illustrating the issue

My Theme:

<style name="AppThemeToolbar" parent="Theme.AppCompat.Light.NoActionBar">
    <item name="colorPrimary">@color/primary_color</item>
    <item name="colorPrimaryDark">@color/primary_color_dark</item>
    <item name="colorAccent">@color/accent_color</item>
    <item name="android:textColorPrimary">@android:color/white</item>
    <item name="android:textColorSecondary">@android:color/white</item>

    <item name="windowActionModeOverlay">true</item>
    <item name="actionModeBackground">@color/action_mode_color</item>
    <item name="actionBarPopupTheme">@style/ThemeOverlay.AppCompat.Light</item>
</style>

Note: I'm using the exact same Theme in multiple Activities though in 3 out of 5 everything is fine. That's totally mind boggling and doesn't make sense.

So basically the question is: How can I fix this and why is the textcolor in some activities black and in others white (while they're all using the same Theme)?


What I've tried (found in other similar posts):

  1. Setting the panelBackground. This works, unfortunately this isn't a solution for me since the textcolor switches at will between black and white - so there's simply no good background color I could set.
  2. What didn't work:
    • android:panelTextAppearance
    • textAppearanceSmallPopupMenu
    • textAppearanceLargePopupMenu
    • popupMenuStyle
    • android:actionMenuTextColor & actionMenuTextColor
  3. I don't wanna use SpannableStrings - approach seems to hacky
Community
  • 1
  • 1
user3420815
  • 775
  • 9
  • 20
  • It seems that `android:textColorSecondary` is changing the text to white. – GPack Jul 13 '15 at 18:18
  • @GPack even if I change the `textColorSecondary` the textColor remains white unfortunately. – user3420815 Jul 14 '15 at 07:43
  • Since all the themes are Light, that is black text, the question is: from where is going the white text? Maybe are you styling the items at menu.xml level of some activity? – GPack Jul 14 '15 at 11:55
  • @GPack That's the question where the white color comes from. I'm not aware of any way to style the menu items via menu.xml or via java code - so it's safe to say that I'm not doing this. ;) – user3420815 Jul 14 '15 at 13:29
  • and there are not other style or theme references in the toolbar xml? – GPack Jul 14 '15 at 13:38
  • I don't have a solution (yet?) but we're seeing a similar issue, and it seems like the broken colors are when using a Toolbar, and the colors are fine when using an action bar. – mlc Jul 30 '15 at 20:52

3 Answers3

2

Finally found the solution!

<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
    <item name="actionBarPopupTheme">@style/HardwareOptionMenu</item>
</style>

<style name="HardwareOptionMenu" parent="ThemeOverlay.AppCompat.Dark">
    <item name="android:textColorSecondary">@color/white</item>
    <item name="android:colorBackground">@color/black</item>
</style>
Daniele B
  • 19,801
  • 29
  • 115
  • 173
0
 <style name="AppThemeLL" parent="Theme.AppCompat.Light.DarkActionBar">
    <!-- Customize your theme here. -->
    <item name="android:windowActionBar">false</item>
    <item name="android:windowNoTitle">true</item>
    <item name="android:colorBackground">@color/white</item>
    <item name="android:textColorSecondary">@color/white</item>
</style>

This style worked for me and for the activity where you will use this theme extend Activity class.

Example:

public class TestActivity extends Activity
{}

Also your manifest will be

<activity android:name=".TestActivity"
        android:label="Test"
        android:theme="@style/AppThemeLL"/>
Ajit Kumar Dubey
  • 1,383
  • 1
  • 19
  • 33
0

I faced similar issue. You could try this for AppCompat :-

<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
    <item name="actionBarPopupTheme">@style/HardwareOptionMenu</item>
</style>

<style name="HardwareOptionMenu" parent="ThemeOverlay.AppCompat.Dark">
    <item name="android:textColorSecondary">@color/black</item>
    <item name="android:colorBackground">@color/white</item>
</style>
Frosty
  • 500
  • 4
  • 14