Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I disable Night Mode in Android 11?

I tried to delete night theme.xml, and I tried to make color changes in night theme. I also tried

AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO);

But none of these worked.

This is my theme.xml:

<resources xmlns:tools="http://schemas.android.com/tools">
    <!-- Base application theme. -->
    <style name="Theme.app" parent="Theme.AppCompat.DayNight.NoActionBar">
        <!-- Primary brand color. -->
        <item name="colorPrimary">@color/light_blue</item>
        <item name="colorPrimaryVariant">@color/light_blue</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>

</resources>

How can I do it?

like image 352
Faizan Avatar asked Dec 23 '22 16:12

Faizan


2 Answers

Just change both theme files with

<style name="Theme" parent="Theme.MaterialComponents.Light.NoActionBar">
like image 53
Faizan Avatar answered Dec 31 '22 00:12

Faizan


Add this in your App theme

<item name="android:forceDarkAllowed">false</item>
like image 23
Wahdat Jan Avatar answered Dec 31 '22 01:12

Wahdat Jan