15

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

Nikola Despotoski
  • 49,966
  • 15
  • 119
  • 148
DevAndroid
  • 311
  • 3
  • 9
  • Could you check if this answer helps you? https://stackoverflow.com/questions/71858592/textfield-is-overlapped-by-keyboard-in-android-compose/71898636#71898636 – nglauber Jun 06 '22 at 18:52

2 Answers2

1

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
}
Nikhil Dupally
  • 753
  • 1
  • 4
  • 12
1

put this in your app AndroidManifest.xml inside activity tag

<activity
    ...
    android:windowSoftInputMode="adjustResize|stateVisible">
Al-Taie
  • 173
  • 6