首页 > 解决方案 > 夜间模式不会更新启动画面的颜色

问题描述

我正在使用 XML 方法来实现我的启动画面(为了避免在冷启动期间出现该空白屏幕)。但问题是我的背景不会随着夜间模式而改变,它仍然是白色的。任何人都可以指导我吗?

res\drawable\splash_screenbg.xml

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:drawable="@color/mainBG" />
    <!--
    <item>
        <bitmap
            android:gravity="center"
            android:src="@drawable/signin_img"/>
    </item>
    -->
</layer-list>

而我的主题/主题-夜间资源文件包含这种样式 res\themes.xmlres\themes.xml(night)

<!--Splash Screen-->
    <style name="SplashScreen" parent="Theme.StookPTU">
        <item name="android:windowBackground">@drawable/splash_screenbg</item>
    </style>

这是我的清单文件 manifests\AndroidManifest.xml中的片段

<activity
            android:name=".SplashScreen"
            android:screenOrientation="portrait"
            android:theme="@style/SplashScreen">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>

        </activity>
        <activity
            android:name=".MainActivity"
            android:launchMode="singleTop"
            android:screenOrientation="portrait">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.DEFAULT" />
            </intent-filter>
        </activity>

标签: androidxmlsplash-screen

解决方案


添加到 colors.xml ( night ):

<color name="mainBG">#000000</color>

或将颜色更改为您的自定义颜色。


推荐阅读