TL,DR;
ContextCompat.getColor() does not use the night colors (values-night/colors.xml) though it should when night mode is enabled.
Here is the problem:
Hi everyone,
So I'm implementing a dark theme for my Android app, I call this to enable it :
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES);
I have set colors in values/colors.xml and there dark version in values-night/colors.xml. The colors changes well depending on the nightMode, BUT :
when I use ContextCompat.getColor(getApplicationContext(), R.id.myColor), it uses the normal colors (values/colors.xml) and not the night colors (values-night/colors.xml).
In my build.gradle, I have set these :
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.core:core-ktx:1.2.0-beta01'
Could someone please tell me what am I doing wrong ?
PS : I already looked at the following question and it does not answer this problem https://stackoverflow.com/questions/57779661/contextcompat-getcolor-method-ignores-night-mode