[M3/DynamicColors] Dynamic Colors not applied when SplashScreen API is used
See original GitHub issueDescription:
When application or activity launcher theme inherits from Theme.SplashScreen
and we set postSplashScreenTheme
to a theme that inherits from Material3, it does not apply Dynamic Colors when we call DynamicColors.applyToActivitiesIfAvailable(this)
on the Application class.
Expected behavior: Apply Dynamic colors.
Source code: https://github.com/serbelga/ToDometer/tree/feature/dynamicColors
Android API version: Android SDK 31 (Android 12)
Material Library version: 1.5.0
<!-- Base application theme. -->
<style name="Theme.ToDometer" parent="Theme.Material3.DayNight">
...
</style>
<style name="Theme.ToDometer.NoActionBar">
...
</style>
<style name="Theme.ToDometer.Starting" parent="Theme.SplashScreen">
<item name="windowSplashScreenBackground">@color/navy</item>
<item name="windowSplashScreenAnimatedIcon">@drawable/ic_launcher_foreground</item>
<item name="windowSplashScreenAnimationDuration">2000</item>
<item name="postSplashScreenTheme">@style/Theme.ToDometer.NoActionBar</item>
</style>
AndroidManifest.xml
<application
android:name=".App"
...
- android:theme="@style/Theme.ToDometer.NoActionBar">
+ android:theme="@style/Theme.ToDometer.Starting">
Issue Analytics
- State:
- Created 2 years ago
- Reactions:1
- Comments:6 (2 by maintainers)
Top Results From Across the Web
How can I use dynamic colors in SplashScreen api an android ...
My problem wasn't that I cannot theme the splash screen, it was that I can not use the system dynamic colors (monet colors)...
Read more >Migrate your existing splash screen implementation to Android ...
Once you migrate, the new API improves startup time, gives you full control over the splash screen experience, and ensures a more consistent...
Read more >Implementing Core Splashscreen API | by Igor Escodro
If this step is not followed, the application will fail with: java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or ...
Read more >A Comprehensive Guide to Android 12's Splash Screen API
postSplashScreenTheme — This is used for defining the actual app theme you want to be used after the splash screen finishes. You should...
Read more >Exploring Android 12: Splash Screen | Joe Birch
Now come Android 12, we have the new Splash Screen APIs. ... *I'm not entirely sure what color is being used for this...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I solved this issue by calling
DynamicColors.applyToActivityIfAvailable(this)
afterinstallSplashScreen()
. Don’t useDynamicColors.applyToActivitiesIfAvailable(this)
in your Application class.I don’t have access to your github link. Where do you call DynamicColors.applyToActivitiesIfAvailable(this) and installSplashScreen()?
You may want to avoid using postSplashScreenTheme since I guess it will override the dynamic color theme overlay we set. Or you can also try to set postSplashScreenTheme to ThemeOverlay.Material3.DynamicColors.DayNight and see if it works in your case?