簡體   English   中英

如何在 SplashScreen api 和 android 12 中使用動態顏色?

[英]How can I use dynamic colors in SplashScreen api an android 12?

我正在嘗試使 android 12 啟動屏幕的背景使用 @android:color/system_neutral1_900 作為背景,但正如我所見,顏色僅在啟動屏幕后加載。 有沒有辦法在啟動畫面上使用它?

<style name="Theme.App.SplashScreen" parent="Theme.SplashScreen">
    <!-- Set the splash screen background, animated icon, and animation duration. -->
    <item name="windowSplashScreenBackground">@android:color/system_neutral1_900</item>
</style>

顏色不會出現,它使用默認的灰色。 我還嘗試了其他 system_ 顏色,結果也一樣。 使用 @android:color/black 或十六進制顏色有效。

根據此鏈接嘗試將此項目用作主要應用程序主題的一部分

 <!-- Base application theme. -->
<style name="AppTheme" parent="Theme.MaterialComponents.Light.NoActionBar">
    <!-- Customize your theme here. -->
    <item name="colorPrimary">@color/colorPrimary</item>
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
    <item name="colorAccent">@color/colorAccent</item>
    <item name="android:windowSplashScreenBackground">@color/colorAccent</item>
</style>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM