Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Keyboard hides TextField first time

I have create a simple example with six TextFields inside a LazyColumn, when you click the last TextField, the keyboard hides it, if you hide the keyboard and click again last TextField, works fine.

In the AndroidManifest I use "adjustPan"

        android:windowSoftInputMode="adjustPan"

This is a capture when you click the last TextField first time, hides the last TextField

This is a capture when you click the last TextField second time, works correctly

This is the code

class MainActivity : ComponentActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContent {
            TestComposeTheme {
                val numbers = listOf(1,2,3,4,5,6)
                LazyColumn() {
                    items(numbers) { index->
                        TextField(index = index)
                    }
                }
            }
        }
    }
}
@Composable
fun TextField(index: Int){
    var text by remember { mutableStateOf("Hello$index") }
    TextField(
        modifier = Modifier.padding(25.dp),
        value = text,
        onValueChange = { text = it },
        label = { Text("TextField$index") }
    )
}

Does anyone know if there is any way that the first time the last TextField is tapped, it would prevent the keyboard from hiding it

EDIT: There is a known issue: 192043120

like image 290
DevAndroid Avatar asked Dec 18 '25 19:12

DevAndroid


1 Answers

This is already a known issue. https://issuetracker.google.com/issues/192043120

One hack to overcome this is use a column with verticalScroll

    Column(Modifier.verticalScroll(rememberScrollState(), reverseScrolling = true){
   // Content
}
like image 194
Nikhil Munna Avatar answered Dec 21 '25 08:12

Nikhil Munna



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!