Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android - Dark mode issue: black text on dark background

When I enable the dark mode some menu on my app looking bad: black text on very dark background. I'm totally a beginner on color things.

enter image description here

I never touched anything on the default color settings on android studio yet, so I have the default two themes XMLs and Color Xml:

     <resources xmlns:tools="http://schemas.android.com/tools">
     <!-- Base application theme. -->
     <style name="Theme.TestSS" parent="Theme.MaterialComponents.DayNight.DarkActionBar">
         <!-- Primary brand color. -->
         <item name="colorPrimary">@color/purple_500</item>
         <item name="colorPrimaryVariant">@color/purple_700</item>
         <item name="colorOnPrimary">@color/white</item>
         <!-- Secondary brand color. -->
         <item name="colorSecondary">@color/teal_200</item>
         <item name="colorSecondaryVariant">@color/teal_700</item>
         <item name="colorOnSecondary">@color/black</item>
         <!-- Status bar color. -->
         <item name="android:statusBarColor" tools:targetApi="l">?attr/colorPrimaryVariant</item>
         <!-- Customize your theme here. -->
     </style>

     <style name="Theme.TestSS.NoActionBar">
          <item name="windowActionBar">false</item>
          <item name="windowNoTitle">true</item>
     </style>

     <style name="Theme.TestSS.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" />

     <style name="Theme.TestSS.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" />
   </resources>

And:

    <resources xmlns:tools="http://schemas.android.com/tools">
    <!-- Base application theme. -->
     <style name="Theme.TestSS" parent="Theme.MaterialComponents.DayNight.DarkActionBar">
         <!-- Primary brand color. -->
         <item name="colorPrimary">@color/purple_200</item>
         <item name="colorPrimaryVariant">@color/purple_700</item>
         <item name="colorOnPrimary">@color/black</item>
         <!-- Secondary brand color. -->
         <item name="colorSecondary">@color/teal_200</item>
         <item name="colorSecondaryVariant">@color/teal_200</item>
         <item name="colorOnSecondary">@color/black</item>
         <!-- Status bar color. -->
         <item name="android:statusBarColor" tools:targetApi="l">?attr/colorPrimaryVariant</item>
         <!-- Customize your theme here. -->
     </style>
    </resources>

Color:

   <?xml version="1.0" encoding="utf-8"?>
     <resources>
      <color name="purple_200">#FFBB86FC</color>
      <color name="purple_500">#FF6200EE</color>
      <color name="purple_700">#FF3700B3</color>
      <color name="teal_200">#FF03DAC5</color>
      <color name="teal_700">#FF018786</color>
      <color name="black">#FF000000</color>
      <color name="white">#FFFFFFFF</color>
     </resources>

where is the issue? I'm testing with AVD on Android R and on my phisical device with Android Q. Thanks for the help

like image 475
Andry Avatar asked Nov 23 '20 15:11

Andry


People also ask

How do I fix black background on Android?

Open your device's Settings app . Select Accessibility. Under "Display," select Color inversion. Turn on Use color inversion.

Why is Google black now?

Why has Google made the change? OLED screens are becoming more and more popular, both on phones and laptops. The true black background makes colours pop more, and makes text appear clearer. Google seems to be testing a new color scheme for its dark mode search results.

Why is my Google background black on my phone?

Google Chrome has a feature called Dark mode (or Dark theme on Android devices) that is aimed to provide a comfortable Web browsing experience when in low light. It turns the interface as well as elements including your homepage, toolbar, and settings into a dark colour scheme to help reduce eyestrain.

What is dark mode on text?

Android Messages offers a feature called “Dark Mode” for their official Android app. This setting can help to prevent eyestrain at night and in darkness.


6 Answers

Change the color in this line to something else and that should do it

     <item name="android:textColor">@android:color/holo_red_light</item>
like image 29
Ayush Pal Avatar answered Oct 16 '22 22:10

Ayush Pal


To change the menu background, add the following line to your style:

<item name="android:itemBackground">@color/your_color</item>
like image 26
private static Avatar answered Oct 16 '22 23:10

private static


Go to your activity_main.xml and set the textColor attributes of the TextViews whose colors remain black to

android:textColor = "?android:textColorPrimary"

Go to res/values/themes/themes.xml (night) and add the code below just under the <!-- Customize your theme here. -->:

<item name="android:textColorPrimary">@color/white</item>

Go to res/values/themes/themes.xml and add the code below just under the <!-- Customize your theme here. -->:

<item name="android:textColorPrimary">@color/black</item>

Run your app and change to dark mode. It'll work. just ensure the codes are added before the </style> closing tags in themes.xml and themes.xml (night) files

like image 155
Cephas Avatar answered Oct 16 '22 23:10

Cephas


To Change the Color in Night in white and light in Black then use below Code.

• Open res/drawable/values/themes.xml and put this code in it.

     <item name="android:textColorPrimary">@color/black</item>

• then Open res/drawable/values/themes.xml(night) and puth this code in it.

   <item name="android:textColorPrimary">@color/white</item>

• and last step Apply in TextView of Activity or fragment put this line in it.

  android:textColor = "?android:textColorPrimary"

Done Keep Code ☻♥

like image 39
Nikhil S Marathe Avatar answered Oct 17 '22 00:10

Nikhil S Marathe


how you set the text colour there is no colour set for text?

try to change this value @color/black because it is the only color match the text colour

like image 1
Jey Avatar answered Oct 17 '22 00:10

Jey


Just need to add this @color/white,make sure you have declare your theme name in manifest.

<style name="Theme.UserRestaurant" parent="Theme.MaterialComponents.Light.DarkActionBar">
    <!-- Primary brand color. -->
    <item name="colorPrimary">@color/orange</item>
    <item name="colorPrimaryVariant">@color/orange_dark</item>
    <item name="colorOnPrimary">@color/white</item>
    <item name="android:background">@color/white</item>


    <!-- Secondary brand color. -->
    <item name="colorSecondary">@color/teal_200</item>
    <item name="colorSecondaryVariant">@color/teal_700</item>
    <item name="colorOnSecondary">@color/black</item>
    <!-- Status bar color. -->
    <item name="android:statusBarColor" tools:targetApi="l">?attr/colorPrimaryVariant</item>
    <!-- Customize your theme here. -->
</style>
like image 1
Anjana Chauhan Avatar answered Oct 17 '22 00:10

Anjana Chauhan