Keyboard hides TextField first time
Asked Answered
O

2

17

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

Odessaodetta answered 23/9, 2021 at 13:52 Comment(1)
Could you check if this answer helps you? #71859092Kinsey
I
4

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
}
Inconsecutive answered 8/9, 2022 at 15:2 Comment(0)
B
4

put this in your app AndroidManifest.xml inside activity tag

<activity
    ...
    android:windowSoftInputMode="adjustResize|stateVisible">
Begone answered 16/11, 2022 at 17:38 Comment(1)
This combined with .imePadding() fixed it for me!Alonso

© 2022 - 2024 — McMap. All rights reserved.