我需要完全透明的系统栏通过滑动来显示然后隐藏。现在应用程序启动时它会隐藏
。
但是滑动后它不会隐藏。
我尝试过使用
systemBarsBehavior = WindowInsetsControllerCompat.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE
但这并没有帮助。请帮忙!
代码
setContent {
Puzzle_QuestTheme {
Surface(
modifier = Modifier.fillMaxSize(),
color = MaterialTheme.colorScheme.background
) {
val systemUiController = rememberSystemUiController()
systemUiController.setStatusBarColor(color = Transparent)
systemUiController.setNavigationBarColor(color =Transparent,darkIcons = false)
systemUiController.isNavigationBarContrastEnforced = false
systemUiController.isNavigationBarVisible = false
systemUiController.isSystemBarsVisible = false
systemUiController.isStatusBarVisible = false
PuzzleQuestApp()
}
}
}
设置systemBarsBehavior后
setContent {
Puzzle_QuestTheme {
Surface(
modifier = Modifier.fillMaxSize(),
color = MaterialTheme.colorScheme.background
) {
val systemUiController = rememberSystemUiController()
val window = LocalContext.current.window
LaunchedEffect(Unit) {
val controller = WindowInsetsControllerCompat(window, window.decorView)
controller.systemBarsBehavior = WindowInsetsControllerCompat.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE
controller.hide(WindowInsetsCompat.Type.systemBars())
}
systemUiController.setStatusBarColor(color = Color.Transparent)
systemUiController.setNavigationBarColor(color = Color.Transparent, darkIcons = false)
systemUiController.isNavigationBarContrastEnforced = false
PuzzleQuestApp()
}
}
}