I was trying to add support to the Android 12 splash screen.
Here's my v31/styles.xml
<resources>
<style name="SplashTheme" parent="Theme.AppCompat.Light.NoActionBar">
<item name="android:statusBarColor">@android:color/transparent</item>
<item name="android:windowFullscreen">true</item>
<item name="android:navigationBarColor">@android:color/transparent</item>
<item name="android:windowSplashScreenAnimatedIcon">@drawable/ic_launcher_foreground</item>
<item name="android:windowSplashScreenIconBackgroundColor">#FF3044</item>
<item name="android:windowSplashScreenBackground">#FF3044</item>
</style>
</resources>
I am able to see a white screen after the new splash. That white screen is the android:windowBackground but if I tried to set it as @null, I am getting inverted splash at the place of the white screen.
How to remove that white background after the splash? Splash API was designed to replace windowBackground I guess.
App flow -> SplashActivity (with the mentioned theme) and then I pause the preDraw method using a ViewModel then navigate to another activity.
SplashActivity.kt - onCreate()
val content: View = findViewById(android.R.id.content)
content.viewTreeObserver.addOnPreDrawListener(
object : ViewTreeObserver.OnPreDrawListener {
override fun onPreDraw(): Boolean {
return if (viewModel.appInit()) {
navigateToHome()
content.viewTreeObserver.removeOnPreDrawListener(this)
true
} else {
false
}
}
}
)
HomeActivity doesn't have any theme. When I add <item name="android:windowBackground">@color/android:black</item> in the Splash's theme, instead of the white screen, I'm getting the black one.