【问题标题】:Splash Screen's color is not updated by Night Mode夜间模式不会更新启动画面的颜色
【发布时间】:2021-07-22 21:16:14
【问题描述】:

我正在使用 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>

And My Theme / Theme- Night Resource 文件包含此样式 res\themes.xml 要么 res\themes.xml(夜晚)

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

这是我的清单文件中的片段 清单\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>

【问题讨论】:

    标签: android xml splash-screen


    【解决方案1】:

    添加到colors.xml(夜晚):

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

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

    【讨论】:

      猜你喜欢
      • 2021-03-14
      • 2021-07-09
      • 2020-06-23
      • 2023-03-08
      • 2020-05-23
      • 1970-01-01
      • 1970-01-01
      • 2021-12-20
      • 1970-01-01
      相关资源
      最近更新 更多