Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Dark Mode: My menu text is black on dark gray, why is that so?

Light mode is fine, Dark Mode is nearly not readable. The menu XML contains this (items reduced)

<menu xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    tools:context="com.example.petesTimer.MainActivity">
    <item
        android:id="@+id/action_MenuSetTime1"
        android:orderInCategory="100"
        android:title="@string/menuEntrySetTime1"
        app:showAsAction="never" />
</menu>

I tried changing the theme xml but it doesnt affect menu text color. Even if I take out black from theme completely and only have like red and blue, the text color for menu items remains black. Anyone an idea what to do ?

ps.: Also added this commonly suggested line to my themes:

    <item name="android:actionMenuTextColor">@color/my_menuTextColor</item>

But its doesnt take it, remains black.

like image 824
IvanMolow Avatar asked Nov 21 '25 18:11

IvanMolow


1 Answers

in res/values/themes.xml in the section refered to by the android:theme section in your manifest file add

<item name="android:textColor">#000000</item>

for black text in daytime and in the res/values-night/themes.xml add

<item name="android:textColor">#FFFFFF</item>

for white text at night.

P.S. Just tried on a freshly created app with minSdk 19 and targetSdk 32 on an android 10 device. Didn't try @color... however.

like image 95
steven smith Avatar answered Nov 23 '25 08:11

steven smith



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!