I'm working on an Android app where I want to change the status bar transparency in a DetailFragment. I've implemented a function transparentStatusBar to achieve this. When I call transparentStatusBar(true) in the DetailFragment, the status bar becomes transparent, but when I press the return button to go back to the previous fragment, the height of the bottomNavigationView gets messed up.
Here's the code for the transparentStatusBar function:
fun Activity.transparentStatusBar(transparent: Boolean) { if (transparent) { WindowCompat.setDecorFitsSystemWindows(window, false) window.statusBarColor = Color.TRANSPARENT } else { WindowCompat.setDecorFitsSystemWindows(window, true) window.statusBarColor = Color.parseColor("#F8FDFF") } } And in the DetailFragment, I'm calling it like this:
requireActivity().transparentStatusBar(true) Here's a before and after screenshot of the bottomNavigationView:
It seems that setting WindowCompat.setDecorFitsSystemWindows(window, false) is causing the issue. How can I prevent this issue and maintain the correct bottomNavigationView height when changing the status bar transparency in the DetailFragment?
Any insights or suggestions would be greatly appreciated. Thank you!