Jetpack Compose - 更改 ModalBottomSheetLayout 中的默认可见百分比
Jetpack Compose - Change default Visible % in ModalBottomSheetLayout
我的 Compose 视图中有一个 ModalBottomSheetLayout
项目列表,可以通过一些 UI 交互来显示。
默认情况下,调用bottomSheetState.show()
时,BottomSheet 的可见比例为50%。但是,从用户体验的角度来看,这并不理想,因为用户必须实际拉起底部 sheet 才能看到列表中的所有内容。
非常令人沮丧的是 bottomSheetState.show()
不 接受任何参数,而且 50% 的值似乎是硬编码的。根据声明在 androix.compose.material
:
suspend fun show() {
val targetValue =
if (isHalfExpandedEnabled) HalfExpanded
else Expanded
animateTo(targetValue = targetValue)
}
我想在显示底部 sheet 时显示一个自定义值,比如 75%,但到目前为止我还没有找到这样做的方法。有解决办法吗?
我不确定你是否可以将其设为 75% 可见,但你可以将其展开显示
bottomSheetState.animateTo(ModalBottomSheetValue.Expanded)
我的 Compose 视图中有一个 ModalBottomSheetLayout
项目列表,可以通过一些 UI 交互来显示。
默认情况下,调用bottomSheetState.show()
时,BottomSheet 的可见比例为50%。但是,从用户体验的角度来看,这并不理想,因为用户必须实际拉起底部 sheet 才能看到列表中的所有内容。
非常令人沮丧的是 bottomSheetState.show()
不 接受任何参数,而且 50% 的值似乎是硬编码的。根据声明在 androix.compose.material
:
suspend fun show() {
val targetValue =
if (isHalfExpandedEnabled) HalfExpanded
else Expanded
animateTo(targetValue = targetValue)
}
我想在显示底部 sheet 时显示一个自定义值,比如 75%,但到目前为止我还没有找到这样做的方法。有解决办法吗?
我不确定你是否可以将其设为 75% 可见,但你可以将其展开显示
bottomSheetState.animateTo(ModalBottomSheetValue.Expanded)