Android官方在api30之后使用 WindowInsetsController控制 window
fun inStatusBar() {
//窗口填充、状态栏透明、动态控制状态栏light模式、动态控制底部导航位置
WindowCompat.setDecorFitsSystemWindows(window, false)
window.statusBarColor = Color.TRANSPARENT
val controller = ViewCompat.getWindowInsetsController(mBinding.root)
controller?.isAppearanceLightStatusBars = lightMode
ViewCompat.setOnApplyWindowInsetsListener(mBinding.root
) { v, insets ->
val sysWindow = insets?.getInsets(WindowInsetsCompat.Type.systemBars())
v?.updatePadding(bottom = sysWindow!!.bottom)
insets
}
}