3

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 = {})
        }

    }

2 Answers 2

1

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 = {})
    }

}
Sign up to request clarification or add additional context in comments.

Comments

1

If anyone is wondering this is how I solved the issue, inside scaffold content you just have to apply padding first, and then apply fillMaxSize():

Column(
        modifier = Modifier
            .padding(it)
            .fillMaxSize()
            .verticalScroll(rememberScrollState())

    ) {

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

1 Comment

Good catch, man Compose Modifiers are a fine art...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.