prakash Mp
prakash Mp

Reputation: 363

How to disable night mode in my application even if night mode is enable in android Q?

i want to disable dark mode in my application(Android Q) .. i tired many ways not yet getting solution for this . could you please suggest perfect solution for this.

AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO);

getDelegate().setLocalNightMode(AppCompatDelegate.MODE_NIGHT_NO); 

Upvotes: 2

Views: 685

Answers (2)

NIKOLAOS KOSMATOS
NIKOLAOS KOSMATOS

Reputation: 13

maybe you can disable it either for all over the app with the line in the onCreate

AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO)

or just for a single Activity:

getDelegate().setLocalNightMode(AppCompatDelegate.MODE_NIGHT_NO);

after that you will need to recreate() in order to use it again.

Upvotes: 0

Kasun Thilina
Kasun Thilina

Reputation: 1681

Add the below line to your styles xml. That'll remove the forced dark option

 <item name="android:forceDarkAllowed" tools:targetApi="q">false</item>

Upvotes: 1

Related Questions