Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Balloon Causes Black Screen During Splash Screen in Compose #786

Open
cgaisl opened this issue Feb 22, 2025 · 0 comments
Open

Balloon Causes Black Screen During Splash Screen in Compose #786

cgaisl opened this issue Feb 22, 2025 · 0 comments

Comments

@cgaisl
Copy link

cgaisl commented Feb 22, 2025

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")
        }
    }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant