Can’t disable Night Mode in my application even with values-night


The problem is that when I look at the preview on the software everything is fine, but when I run the app on my phone everywhere is used the color white it turn dark (drawables and backgrounds). I haven’t used an alpha on the drawables, only android:color"@color/white".

The source of the problem is that my phone had the Night Mode enable, so it automatically changed the colors in the app.

To try to disable the Night Mode I created a folder values-night and copied my @styles and @colors to match the Day and Night Mode.

styles.xml (night)


    <!-- Base application theme. -->
        <style name"MyTheme" parent"Theme.AppCompat.Light.NoActionBar">
        <!-- Customize your theme here. -->
        <item name"android:windowBackground">@color/colorAccent</item>
        <item name"colorPrimary">@color/colorPrimary</item>
        <item name"colorPrimaryDark">@color/colorPrimaryDark</item>
        <item name"colorAccent">@color/colorAccent</item>


colors.xml (night)

<?xml version"1.0" encoding"utf-8"?>
    <color name"colorPrimary">#1d1d1d</color>
    <color name"colorPrimaryDark">#1d1d1d</color>
    <color name"colorAccent">#F8F8F8</color>
    <color name"textColor">#1d1d1d</color>

In my MainActivity.xml


In my Manifest.xml


I checked the answers on How to disable night mode in my application even if night mode is enable in android 9.0 (pie)? and Dark Theme in android 9.0 changes my app layouts ugly and did the values-night folder, but it didn’t resolve the problem.

But the problem persist, any idea what am I missing here? Thanks in advance.


I had the same issue on my Xiaomi Redmi Note 7. I tried this code inside MainActivity.create():


But it doesn’t work on some of Xiaomi devices including mine, though it works on other phones.

So the only solution I’ve found is to add <item name"android:forceDarkAllowed" tools:targetApi"q">false</item> to each of your AppTheme in styles.xml. Like this:

<style name"MyTheme" parent"Theme.AppCompat.Light.NoActionBar">
    <item name"android:forceDarkAllowed" tools:targetApi"q">false</item>

It worked fine for my phone.

Answered By – Captain Jorjik

Leave a Comment