简体   繁体   中英

Bottom navigation bar overlap button in jetpack compose

This is my compose app.

Scaffold( // main content
    modifier = Modifier.fillMaxSize(),
    scaffoldState = scaffoldState
) {
    Surface(
        modifier = Modifier
            .fillMaxSize()
            .padding(it),
        color = MaterialTheme.colors.background
    ) {
        NavGraph(navController)
    }
}
// my main screen
Column(
    Modifier.fillMaxSize()
) {
    Column(modifier = Modifier.weight(1f)) {
        HeaderView()
        // other element
    }
    Spacer(modifier = Modifier.height(Padding16))
    ButtonPrimary(
        modifier = Modifier.padding(horizontal = Padding24),
        text = stringResource(id = R.string.accept_and_continue),
        onClick = {
            onContinueClick()
        })
    Spacer(modifier = Modifier.height(Padding16))
}

For most of the devices, the code above was working fine. However, when I tested on a Samsung 21, and Android 12, the bottom button was cut off as below image. Does anyone know the cause and how to solve it?

按钮被切断

Seems like your app is under the navigation bar. Try adding a .navigationBarsPadding() modifier to your screen's Column

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM