My screen consists of BottomNavigation and NavHost. I want the root element of the screen to fully handle systemBars insets and these insets are not passed on to its children. To do this, I wrote the following code. In the builder, I pass systemBars insets equal to 0.
ViewCompat.setOnApplyWindowInsetsListener(binding.root) { view, insets ->
binding.root.updatePadding(
bottom = insets.getInsets(WindowInsetsCompat.Type.systemBars()).bottom,
)
val newI = WindowInsetsCompat.Builder()
.setInsets(WindowInsetsCompat.Type.systemBars(), Insets.of(Rect(0,0,0,0)))
.build()
newI
}
ViewCompat.setOnApplyWindowInsetsListener(binding.navHostFragmentMain) { view, insets ->
val sysBars = insets.getInsets(WindowInsetsCompat.Type.systemBars())
insets
}
In theory, navHost should not receive systemBars insets, since they are processed by its parent. But I still get systemBars insets not equal to 0. The insets I get are equal to the insets of the parent. What am I doing wrong?