Hi all. Has anyone solved the issue where the keyb...
# compose
s
Hi all. Has anyone solved the issue where the keyboard covers the input text? I know there are two ways to “fix” it, but both are not acceptable for me: 1. Set a fixed height for the text field — but I want to show all text on screen. 2. Remove
.verticalScroll(rememberScrollState())
- needs full text to remain visible. Any ideas? See the video.
For Activity added:
Copy code
android:windowSoftInputMode="adjustResize"
Compose:
Copy code
Scaffold(modifier = Modifier.fillMaxSize()) { innerPadding ->
    Column(
        modifier = Modifier
            .fillMaxSize()
            .padding(innerPadding)
            .verticalScroll(rememberScrollState())
    ) {
        Text("Welcome!", style = MaterialTheme.typography.bodyLarge)

        Text("Please add description!", style = MaterialTheme.typography.bodyLarge)

        var text by remember { mutableStateOf("") }

        TextField(
            value = text,
            onValueChange = {
                text = it
            },
            modifier = Modifier
                .fillMaxWidth()
                .imePadding(),
            singleLine = false
        )

        Text("This will be some checkbox!", style = MaterialTheme.typography.bodyLarge)
        Text("Happy New YEAR!", style = MaterialTheme.typography.bodyLarge)
    }
}
t
Just use the
.imePadding()
modifier ?
v
You should consume insets (e.g.
Modifier.imePadding()
) instead of setting
android:windowSoftInputMode="adjustResize"
s
@Tolriq @Vilgot Fredenberg Thanks. Unfortunately, your suggestions didn’t work, issue is still the same :(
v
You're using the old textfield which contains an internal vertical scrollbar. Try switching to the newer text field
Copy code
Scaffold { innerPadding ->
    Column(
        modifier = Modifier
            .padding(innerPadding)
            .imePadding()
            .verticalScroll(rememberScrollState())
    ) {
        Text("Welcome!", style = MaterialTheme.typography.bodyLarge)

        Text("Please add description!", style = MaterialTheme.typography.bodyLarge)

        val state = rememberTextFieldState()
        TextField(state, Modifier.fillMaxWidth())

        Text("This will be some checkbox!", style = MaterialTheme.typography.bodyLarge)
        Text("Happy New YEAR!", style = MaterialTheme.typography.bodyLarge)
    }
}
1
👍 1
s
@Vilgot Fredenberg Thank you so much!!! It works!