Search code examples
android-jetpack-composescaffold

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


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

    }

Solution

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