I am implementing edge-to-edge UI in my Android app, but my content is overlapping the status bar on Android 15. I want my layout to adjust properly based on system bars and display cutouts.
As per Android's official documentation (https://developer.android.com/develop/ui/views/layout/edge-to-edge), I am using the following code to handle window insets:
ViewCompat.setOnApplyWindowInsetsListener(binding.recyclerView) { v, insets ->
val bars = insets.getInsets(
WindowInsetsCompat.Type.systemBars() or WindowInsetsCompat.Type.displayCutout()
)
v.updatePadding(
left = bars.left,
top = bars.top,
right = bars.right,
bottom = bars.bottom
)
WindowInsetsCompat.CONSUMED
}