即使在android 9.0(pie)中启用了夜间模式,如何在我的应用程序中禁用夜间模式? [英] How to disable night mode in my application even if night mode is enable in android 9.0 (pie)?

查看:94
本文介绍了即使在android 9.0(pie)中启用了夜间模式,如何在我的应用程序中禁用夜间模式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在发布android pie之前创建了我的应用程序,在我放置的每个布局中, android:background ="white" 在所有设备上都可以正常工作,但是当我的兄弟安装了该应用程序并启用时夜间模式我的应用程序一动不动就变成了一场灾难,一切都变成了黑白电影.

I created my application before the android pie has been released, in every layout I put android: background = "white" it works fine in every device, but when my brother installed the application and enabled night mode my application becomes a disaster with one single move, everything turns into back and white movie.

<style name="AppTheme" parent="Theme.AppCompat.DayNight.DarkActionBar">
    <!-- Customize your theme here. -->
    <item name="colorPrimary">@color/COLOR_PRIMARY</item>
    <item name="colorPrimaryDark">@color/COLOR_PRIMARY</item>
    <item name="colorAccent">@color/COLOR_PRIMARY</item>
    <item name="cardViewStyle">@style/CardView</item>
    <item name="android:fontFamily">@font/helvetica</item>
</style>

我的原色是红色.

推荐答案

您可以将其放在启动器活动的 onCreate 方法的第一行.

You can put this, at the first line in the onCreate method of your launcher activity.

    AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO)

这篇关于即使在android 9.0(pie)中启用了夜间模式,如何在我的应用程序中禁用夜间模式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆