Android 15 makes edge-to-edge display the default behavior. While this makes apps look great, it can break existing layouts by drawing content behind the status bar or navigation bar. If you haven't updated your insets handling, your buttons might be unclickable!
The enableEdgeToEdge Call
The first step is to call enableEdgeToEdge() in your Activity's onCreate.
This tells the system that your app is ready to handle the full screen area.
override fun onCreate(savedInstanceState: Bundle?) {
enableEdgeToEdge()
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
}
Handling Window Insets
You MUST apply padding to your root view to account for the system bars. If you don't, your top toolbar will overlap with the notification icons.
ViewCompat.setOnApplyWindowInsetsListener(rootView) { v, insets ->
val systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars())
v.updatePadding(top = systemBars.top, bottom = systemBars.bottom)
insets
}
Compose Safe Area
In Jetpack Compose, use the Modifier.safeDrawingPadding() or
Modifier.systemBarsPadding()
to automatically handle insets without manual calculations. It's much cleaner and less error-prone.
Scaffold(
modifier = Modifier.fillMaxSize().systemBarsPadding()
) { ... }
Summary
Embrace the edge-to-edge future but handle your insets correctly. Use `ViewCompat` or Compose modifiers to keep your UI functional and beautiful. No more overlapping bars!