Home > Software engineering >  How to prevent white background when app starts up in Jetpack compose
How to prevent white background when app starts up in Jetpack compose

Time:11-21

I have created an app with Jetpack compose and expected the start up background is black or some other colors, not white. This is my themes.xml

<style name="Theme.AlluringScreenshot" parent="Theme.MaterialComponents.DayNight.DarkActionBar">
    <item name="android:statusBarColor">#030318</item>
    <item name="android:windowBackground">#030318</item>
</style>

The above style works well till on Android 11 but Android 12. My app still has white background at starting up. Any suggestions for this matter?

CodePudding user response:

Use the splash screen API as a placeholder while jetpack compose is still processing

CodePudding user response:

This is the author of this question.

After spending more time diving into some documents, I have found the spot for this matter. It looks very simple than any the solutions I found. The android:windowBackground attribute only work till Android 11. This should be replaced by android:windowSplashScreenBackground to work well on Android 12.

That's all.

  • Related