-
-
Notifications
You must be signed in to change notification settings - Fork 306
Open
Description
Including a Balloon in a Jetpack Compose UI hierarchy in MainActivity causes the splash screen (via AndroidX SplashScreen API) to display as a black screen while setKeepOnScreenCondition is true.
Expected Behavior:
- After the initial splash screen (white background with an icon), the splash screen stays on for 2 more seconds.
- After 2 seconds, the main UI appears.
Actual Behaviour:
- After the initial splash screen, the app turns black
- After 2 seconds, the main UI appears
Minimal example:
res/values/themes.xml
<resources>
<style name="Theme.App.Starting" parent="Theme.SplashScreen">
<item name="windowSplashScreenBackground">@android:color/white</item>
<item name="windowSplashScreenAnimatedIcon">@drawable/ic_launcher_background</item>
<item name="postSplashScreenTheme">@style/ActualTheme</item>
</style>
<style name="ActualTheme">
<item name="android:windowBackground">@android:color/white</item>
</style>
</resources>
manifest
<activity
android:name=".MainActivity"
android:theme="@style/Theme.App.Starting">
MainActivity.kt
class MainActivity : ComponentActivity() {
private var isDataLoaded = false
override fun onCreate(savedInstanceState: Bundle?) {
val splashScreen = installSplashScreen()
super.onCreate(savedInstanceState)
splashScreen.setKeepOnScreenCondition { !isDataLoaded }
setContent {
Log.d("MainActivity", "setContent")
val balloon = rememberBalloonBuilder { }
Box(
modifier = Modifier.fillMaxSize()
) {
Balloon(
builder = balloon,
balloonContent = {
Text("Balloon Content")
},
) {
Text("Hello, World")
}
}
}
lifecycleScope.launch {
delay(2000)
isDataLoaded = true
Log.d("MainActivity", "data is loaded")
}
}
}
Metadata
Metadata
Assignees
Labels
No labels