Android 中启动屏幕的背景颜色没有改变

问题描述 投票:0回答:1

我正在尝试使用启动屏幕 API 更改启动屏幕的背景颜色,但我不知道为什么它不起作用。 在 Android Studio 模拟器 (API 34) 和我的三星手机 (API 33) 上进行了测试。

主题.xml

<style name="Theme.MyApp" parent="android:Theme.Material.Light.NoActionBar" />

    <style name="Theme.Splash" parent="Theme.SplashScreen">
        <item name="windowSplashScreenIconBackgroundColor">@color/black</item>
        <item name="postSplashScreenTheme">@style/Theme.MyApp</item>
    </style>

MainActivity.kt

 override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        val splashScreen = installSplashScreen()

        setContent {
            // rest of code
        }
}

AndroidManifest.xml

<application
        ...
        android:theme="@style/Theme.Splash"
        ...
</application>
android
1个回答
0
投票

添加

<item name="android:windowSplashScreenBackground">@color/somecolor</item>

© www.soinside.com 2019 - 2024. All rights reserved.