gpt4 book ai didi

android - Jetpack compose 的状态栏中未显示模态 Bottom Sheet 稀松布颜色

转载 作者:行者123 更新时间:2023-12-04 23:42:28 25 4
gpt4 key购买 nike

将 View 系统中的应用程序迁移到 Jetpack compose。
Bottom Sheet 稀松布颜色显示在状态栏 在当前应用程序中。
如何在 Jetpack compose 中重现相同的内容?
使用 View 的应用程序屏幕截图

使用 compose 的应用截图

编写代码

val modalBottomSheetState = rememberModalBottomSheetState(
initialValue = ModalBottomSheetValue.Hidden,
)
val coroutineScope = rememberCoroutineScope()

ModalBottomSheetLayout(
sheetState = modalBottomSheetState,
sheetContent = {
// Not relevant
},
) {
Scaffold(
scaffoldState = scaffoldState,
topBar = {
// Not relevant
},
floatingActionButton = {
FloatingActionButton(
onClick = {
coroutineScope.launch {
if (!modalBottomSheetState.isAnimationRunning) {
if (modalBottomSheetState.isVisible) {
modalBottomSheetState.hide()
} else {
modalBottomSheetState.show()
}
}
}
},
) {
Icon(
imageVector = Icons.Rounded.Add,
contentDescription = "Add",
)
}
},
modifier = Modifier
.fillMaxSize(),
) { innerPadding ->
// Not relevant - Nav graph code
}
}

最佳答案

尝试使用 System UI Controlleraccompanist控制状态栏颜色和导航栏颜色的库

implementation "com.google.accompanist:accompanist-systemuicontroller:0.18.0"
// Remember a SystemUiController
val systemUiController = rememberSystemUiController()
val useDarkIcons = MaterialTheme.colors.isLight

SideEffect {
// Update all of the system bar colors to be transparent, and use
// dark icons if we're in light theme
systemUiController.setSystemBarsColor(
color = Color.Transparent,
darkIcons = useDarkIcons
)

// setStatusBarsColor() and setNavigationBarsColor() also exist
}

关于android - Jetpack compose 的状态栏中未显示模态 Bottom Sheet 稀松布颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/69560253/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com