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
6
  • It seems that android:textColorSecondary is changing the text to white. Commented Jul 13, 2015 at 18:18
  • @GPack even if I change the textColorSecondary the textColor remains white unfortunately. Commented Jul 14, 2015 at 7: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? Commented Jul 14, 2015 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. ;) Commented Jul 14, 2015 at 13:29
  • and there are not other style or theme references in the toolbar xml? Commented Jul 14, 2015 at 13:38

3 Answers 3

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>
Sign up to request clarification or add additional context in comments.

Comments

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"/>

Comments

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>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.