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>