简体   繁体   English

无法在 android 低于 29 时禁用暗模式

[英]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.我是 android 的新手,为当前版本的用户创建了一个用于棉花糖的 android 应用程序,在我的应用程序中,我尝试禁用dark mode ,但它对我不起作用。

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禁用Dark Mode的最简单方法是

android:forceDarkAllowed="false"

in your main_activity.xml root Layout also,在您的main_activity.xmlLayout中,

Override Resource in layout-v29

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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