The Material3 Modal Bottom Sheet is currently overlapping with the system navigation buttons. Is there a way to avoid this overlap with the system navigation buttons.
This is the code that I am using for showing modal bottom sheet
@Composable
fun TestScreen() {
var sheetOpened by mutableStateOf(false)
Scaffold() {
Box(Modifier.fillMaxSize(), contentAlignment = Alignment.Center) {
Button(onClick = { sheetOpened = true }){
Text("Open Bottom Sheet")
}
}
}
if(sheetOpened){
ModalBottomSheet(onDismissRequest = {sheetOpened = false}){
Box(Modifier.fillMaxWidth().height(500.dp).background(Color.RED))
}
}
}
Tried putting the Modal Bottom Sheet inside the Scaffold, but that does not work either.
To address this issue, inform Jetpack Compose that you'll be handling insets manually. Add the following code to your
MainActivity
:Next, calculate the
BottomPadding
of yourBottomModalSheet
using the following approach:Apply this in your
BetterModalBottomSheet
composable as shown in the sample code:For additional details, refer to this post.