Abh*_*bhi 15 android bottom-sheet android-jetpack-compose
将视图系统中的应用程序迁移到 Jetpack compose。
底部稀松布颜色显示在当前应用程序的状态栏上。
如何在 Jetpack 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
}
}
Run Code Online (Sandbox Code Playgroud)
尝试使用伴奏库中的系统UI控制器来控制statusBar Color和navigationBar color
implementation "com.google.accompanist:accompanist-systemuicontroller:0.18.0"
Run Code Online (Sandbox Code Playgroud)
// 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
}
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
5264 次 |
最近记录: |