android-jetpack-composejetpack-compose-modalbottomsheet

keep ModalBottomSheet expanded compose


I have the following code for my bottom sheet.

val skipPartiallyExpanded by remember {
    mutableStateOf(true)
}
val bottomSheetState =
    rememberModalBottomSheetState(skipPartiallyExpanded = skipPartiallyExpanded)

    ModalBottomSheet(
        onDismissRequest = {
            onDismissRequest()
            onSearchTextChange("")
        },
        sheetState = bottomSheetState,
    )

I want to keep the bottom sheet expanded at all time, but it gets smaller whenever the content gets smaller too. I thought that setting skipPartiallyExpanded to true would do the trick, but it is not working as I would expect.


Solution

  • I solve the problem by making the content of the bottom sheet fill the max size.

    modifier = modifier.fillMaxSize()
    

    And of course skipPartiallyExpanded is always true

    val bottomSheetState =
        rememberModalBottomSheetState(skipPartiallyExpanded = true)