androidandroid-jetpack-composeandroid-jetpack-compose-scaffold

Bottom Sheet content is showing for a second before activity content in Jetpack compose


I have implemented bottom sheet in jetpack compose with BottomSheetScaffold in a screen and default state is initialValue = BottomSheetValue.Collapsed. When screen appears on device then Bottom sheet content is displayed for a second and then activity scope layout are presented and then bottom sheet behaves like it should. I am trying to remove this glitch from bottom sheet. Please let me know the suggestions which I can implement to remove this glitch.

Bottom sheet is working fine but it appears for a second before screen content and then disappears. This glitch needs to be removed.


Solution

  • Use a state for initial value storage, try

    rememberModalBottomSheetState(
            initialValue = ModalBottomSheetValue.Hidden,
        )
    

    I use this way to show the bottom sheets

    val bottomSheetState = rememberModalBottomSheetState(
        initialValue = ModalBottomSheetValue.Hidden,
    )
    ModalBottomSheetLayout(
        sheetState = bottomSheetState,
        sheetContent = {
            //Sheet content
        },
        scrimColor = <SCREEN OVERLAY COLOR>,
        sheetBackgroundColor = <BACKGROUND COLOR>
    ) {//Your Screen Code}
    

    Hope this work for you!