我将使用jetpack compose 实现一个屏幕,其中包含底部工作表内容中的aScaffoldBottomSheet
和a 。LazyColumn
我还希望底部工作表的高度是固定的,用户不能折叠它。为了做到这一点,我禁用了工作表手势并为600.dp
底部工作表的内容提供高度。但是当我滚动惰性列的项目时,底部工作表会向下滚动并最终折叠。
这是我的代码:
@ExperimentalMaterialApi
@Composable
fun TestScreen(
testViewModel: TestViewModel = hiltViewModel()
) {
val bottomSheetScaffoldState = rememberBottomSheetScaffoldState(
bottomSheetState = rememberBottomSheetState(
BottomSheetValue.Expanded
)
)
BottomSheetScaffold(
scaffoldState = bottomSheetScaffoldState,
sheetContent = {
Box(modifier = Modifier.fillMaxWidth().height(600.dp)) {
LazyColumn() {
items(20) {
Text(text = "this is for test", modifier = Modifier
.padding(start = 20.dp, top = 20.dp)
.fillMaxWidth()
.height(50.dp))
}
}
}
},
sheetPeekHeight = 0.dp,
sheetShape = RoundedCornerShape(topEnd = 52.dp, topStart = 52.dp),
backgroundColor = AppColor.ThemeColor.BACKGROUND,
sheetGesturesEnabled = false
) {
}
}