Reputation: 363
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
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
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