Jetpack Compose - Scaffold bottom bar hides TextField when keyboard is opened

33 views Asked by At

When I click on the TextField, keyboard opens, but the bottom bar is covering the TextField. Is there a way to make this field visible without programmatically scrolling?

enter image description here

    Scaffold(
        modifier = Modifier.fillMaxSize().navigationBarsPadding().imePadding(),
        bottomBar = {
            Box(
                modifier = Modifier
                    .fillMaxWidth()
                    .padding(10.dp)
            ) {
                DefaultButton(
                    modifier = Modifier.align(Alignment.Center),
                    enabled = true,
                    onClick = {
                    }) {
                    Text(text = "Test")
                }
            }
        }
    ) {
        Column(
            modifier = Modifier
                .fillMaxSize()
                .verticalScroll(rememberScrollState())
                .padding(it)
        ) {

            Box(modifier = Modifier.height(2000.dp).fillMaxWidth().background(Color.Red))
            TextField(value = "Testing", onValueChange = {})
        }

    }
1

There are 1 answers

0
GaneshHulyal On

I see ImePadding is given to BottomBar's box modifier, remove imePadding from the box modifier and add it to the TextFields modifier.

Scaffold(
    modifier = Modifier.fillMaxSize().navigationBarsPadding(),
    bottomBar = {
        Box(
            modifier = Modifier
                .fillMaxWidth()
                .padding(10.dp)
        ) {
            DefaultButton(
                modifier = Modifier.align(Alignment.Center),
                enabled = true,
                onClick = {
                }) {
                Text(text = "Test")
            }
        }
    }
) {
    Column(
        modifier = Modifier
            .fillMaxSize()
            .verticalScroll(rememberScrollState())
            .padding(it)
    ) {

        Box(modifier = Modifier.height(2000.dp).fillMaxWidth().background(Color.Red))
        TextField(modifier = Modifier.imePadding(),value = "Testing", onValueChange = {})
    }

}