I want to implement Splash Screen using Jetpack Compose. In the old View system, we can just change the android:windowBackground via XML Theme.
How to do this in Compose?
As I looked into the AndroidManifest.xml, I saw that the app is still using old themes.xml for its activities.
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.AppName">
From here I just edit the theme to apply a windowBackground
<style name="Theme.AppName" parent="Theme.MaterialComponents.Light.DarkActionBar">
<item name="android:windowBackground">@color/black</item>
</style>
I did not create a new style and just use the main style. It's enough to just apply a white Surface on the root composable to hide the splash background when the activity showed up.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With