androidxmlkotlinandroid-jetpack-composeedge-to-edge

AndroidX's Edge to Edge shows an Action Bar - How to hide it?


I've implemented Edge to Edge in my Android app, I've set the Status/Navigation bars to be transparent, and it works well. However suddenly an ActionBar appeared on top of my screen, even though I've set the app theme to be "android:Theme.Material.Light.NoActionBar". How can I fix that?

MainActivity:

    override fun onCreate(savedInstanceState: Bundle?) {
        enableEdgeToEdge(
            statusBarStyle = SystemBarStyle.light(
                Color.TRANSPARENT, Color.TRANSPARENT
            ),
            navigationBarStyle = SystemBarStyle.light(
                Color.TRANSPARENT, Color.TRANSPARENT
            )
        )
        super.onCreate(savedInstanceState)
    }

Root composable:

...
val view = LocalView.current
if (!view.isInEditMode) {
    SideEffect {
        val window = (view.context as Activity).window
        window.statusBarColor = Color.Transparent.toArgb()
        WindowCompat.getInsetsController(window, view).isAppearanceLightStatusBars = !darkTheme
    }
}
...

themes.xml

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <style name="Theme.TestApp" parent="android:Theme.Material.Light.NoActionBar" />
</resources>

Solution

  • I removed it by calling the splashscreen before the enableEdgeToEdge:

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
    
        installSplashScreen().apply {
            setKeepOnScreenCondition {
                viewModel.isLoading.value
            }
        }
    
        enableEdgeToEdge()
    
        setContent {