Rud*_*ave 6 android kotlin bottom-sheet android-jetpack-compose
我在底部工作表内有一个惰性列。当我向上滚动该列时,工作表也会随之折叠。我尝试将sheetGesturesEnabled 设置为 false,但在我的情况下不起作用。这是一个代码片段。
@OptIn(ExperimentalAnimationApi::class, ExperimentalMaterialApi::class)
@Composable
fun SheetContent() {
Box(
Modifier
.fillMaxWidth()
.heightIn(min = screenHeight, max = screenHeight)
) {
Row(
modifier = Modifier
.fillMaxWidth()
.height(rowHeight)
) {
LazyColumn() {
...
}
LazyColumn() {
...
}
LazyColumn() {
...
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
在这里添加底部工作表实现。我猜测问题一定出在嵌套项目上,即工作表内容中的惰性列。
@OptIn(ExperimentalMaterialApi::class)
@Composable
fun BottomsheetScreen() {
val bottomSheetScaffoldState = rememberBottomSheetScaffoldState(
bottomSheetState = BottomSheetState(BottomSheetValue.Collapsed)
)
val coroutineScope = rememberCoroutineScope()
BottomSheetScaffold(
scaffoldState = bottomSheetScaffoldState,
sheetShape = RoundedCornerShape(32.dp, 32.dp),
sheetElevation = 8.dp,
sheetContent = {
SheetContent()
},
sheetPeekHeight = 0.dp,
sheetGesturesEnabled = false,
drawerGesturesEnabled = false
) {
Button(onClick = {
coroutineScope.launch {
if (bottomSheetScaffoldState.bottomSheetState.isCollapsed) {
bottomSheetScaffoldState.bottomSheetState.expand()
} else {
bottomSheetScaffoldState.bottomSheetState.collapse()
}
}
}) {
Text(text = "Expand/Collapse Bottom Sheet")
}
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4930 次 |
| 最近记录: |