Search code examples
androidandroid-jetpack-composebottom-sheet

How can i set padding to BottomSheetScaffold in jetpack compose


I want to set the start and end padding to BottomSheetScaffold but as you can see, the borromsheet has extra color in the background and has not had good ui. How can i set padding to bottomsheet?

enter image description here

 BoxWithConstraints() {
            val maxHeight = maxHeight
            val sheetHeight = maxHeight / 4.dp
            BottomSheetScaffold(
                modifier = modifier
                    .statusBarsPadding()
                    .navigationBarsPadding(),
                scaffoldState = scaffoldState,
//                sheetShape = RoundedCornerShape(topStart = 16.dp, topEnd = 16.dp),
                sheetContent = {
                   
                },
                sheetBackgroundColor = Color.Unspecified,
                sheetPeekHeight = 51.dp
            ) {
                Box(modifier = modifier
                    .fillMaxSize()) {
                    Column(modifier = modifier
                        .fillMaxSize()) {
                      
                        Box(modifier = modifier
                            .weight(1f)
                            .background(Color.Cyan)) {
                          
                        }
                    }
                }
            }
        }

Solution

  • I faced the same issue recently. I found that this issue is caused by the sheet elevation. By default, sheet elevation is 8dp. Make it 0dp which will make the issue to resolve.