简体   繁体   中英

Can't disable dark mode in android below 29

I'm new to android, creating an android app for marshmallow to current version users, In my app I try to disable dark mode but it is not working for me.

AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO);

<style name="Theme.MyApp" parent="Theme.MaterialComponents.Light.DarkActionBar">

getDelegate().setLocalNightMode(AppCompatDelegate.MODE_NIGHT_NO);

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

I tried this methods but it is not worked for me. How can I achieve this.

The simplest way to disable Dark Mode is

android:forceDarkAllowed="false"

in your main_activity.xml root Layout also,

Override Resource in layout-v29

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM