提问人:Saeed Noshadi 提问时间:10/27/2021 更新时间:7/19/2022 访问量:951
为什么我的 bottomSheet 来自喷气背包撰写中的屏幕顶部
Why my bottomSheet comes from the top of screen in the jetpack compose
问:
我有一个bottomSheet,但是当屏幕显示时,它从屏幕顶部到底部。我该如何解决?
这是我的 bottomSheet 代码:
@ExperimentalMaterialApi
@Composable
fun BottomSheet(
modifier: Modifier = Modifier,
buttonText: String,
composable: @Composable () -> Unit,
scope: CoroutineScope
) {
val bottomSheetScaffoldState = rememberBottomSheetScaffoldState(
bottomSheetState = BottomSheetState(BottomSheetValue.Expanded)
)
BottomSheetScaffold(
scaffoldState = bottomSheetScaffoldState,
sheetContent = {
Column(
Modifier
.fillMaxWidth()
.height(200.dp)
.padding(8.dp),
verticalArrangement = Arrangement.Center,
horizontalAlignment = Alignment.CenterHorizontally
) {
Button(colors = ButtonDefaults.buttonColors(
backgroundColor = AppColor.brandColor.BLUE_DE_FRANCE,
contentColor = AppColor.neutralColor.DOCTOR
),
shape = RoundedCornerShape(
small
),
onClick = {
scope.launch {
bottomSheetScaffoldState.bottomSheetState.collapse()
}
}) {
}
}
},
sheetPeekHeight = 0.dp,
sheetShape = RoundedCornerShape(topEnd = medium, topStart = medium)
) {
composable()
}
}
可组合函数是 Google 地图屏幕
答:
0赞
Alex Peterson
7/19/2022
#1
我的问题仅在预览中。当以交互方式或在模拟器中运行它时,它可以正常工作。如果您还没有,也许可以尝试一下。
评论
composable()
Text()