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

Viewed 120

I'm trying to make the background of an android 12 splash screen use @android:color/system_neutral1_900 as the background, but as I can see, the color loads only after the splash screen. Is there any way to use it on the splash screen?

<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>

The color does not appear and it uses the default grey. I also tried with other system_ colors and the same result comes up. Using @android:color/black or hex colors works.

1 Answers

Try using this item as part of your main application theme according to this link

 <!-- 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>
Related