Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Overflow Menu textColor with AppCompat (using Hardware Menu-Key)

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
like image 700
user3420815 Avatar asked Jul 13 '15 13:07

user3420815


1 Answers

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>
like image 180
Daniele B Avatar answered Nov 15 '22 19:11

Daniele B