Default dark text color in dark mode on the action bar

100 views Asked by At

In light mode I have no problems because everything is correct but in dark mode without making any changes the text remains dark. Is it an Android bug? I have tried various methods but my problem is that I have to disable some menu options and then I lose the color in disabled mode, it always seems enabled. Is it just my problem? In this way the text is illegible I use this theme: Theme.MaterialComponents.DayNight.DarkActionBar

2

There are 2 answers

3
coroutineDispatcher On

You might be reading the colors for both dark and light mode from the same color resource. You need to create another color resource file for dark values and then it should automagically work.

And I am not sure if DarkActionBar is the right one to put there on the theme.

You should have something like this:

res -> values -> colors.xml
res -> values-night -> colors.xml
3
Kevin Kalathiya On

Well, if you don't want the color to when user switch in dark/light mode then remove the night-theme file from res>values

and add change this in remained theme file

    <style name="app_name" parent="Theme.MaterialComponents.DayNight.NoActionBar">

into

<style name="app_name" parent="Theme.MaterialComponents.Light.NoActionBar">

if your parent is different than than change it into oneof light mode of it