Search code examples
androiddarkmodexiaomiandroid-dark-themeandroid-darkmode

Android. Xiaomi (android 10+) mode_night_follow_system wrong color when phone system theme is dark


the problem is:

When I open the application, I set the theme according to the theme of the device. In android code it is = mode_night_follow_system.

Let's imagine that the theme of the system(device) is dark. When logging into the mobile app, I do

  AppCompatDelegate.setDefaultNightMode(mode_night_follow_system)

The application changes the color to dark, but it feels like it does not take my colors indicated in color-dark.

The problem is only for xiaomi phones with android 10+

On other models Samsung, Huawei, etc., there are no problems.

What is the problem?


Solution

  • I had the same issue this solved my problem Speciall the second option.

    1)Add this line in each activity just below onCreate

    AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO);
    
    

    OR

    1. add this line in your themes under style section
    <item name="android:forceDarkAllowed" tools:targetApi="q">false</item>