Struggling with ensuring `TextField`s are visible on screen when the IME/keyboard open after text fi...
s
Struggling with ensuring `TextField`s are visible on screen when the IME/keyboard open after text field focus. I'm trying to use
BringIntoViewRequester
, as per https://blog.canopas.com/keyboard-handling-in-jetpack-compose-all-you-need-to-know-3e6fddd30d9a and https://developer.android.com/reference/kotlin/androidx/compose/foundation/relocation/BringIntoViewRequester?hl=en. When focusing on a text field that's far enough down on the screen, the keyboard overlaps and hides the text field. Sample available at https://github.com/sindrenm/spike-compose-text-field-ime.
1
a
I just created a form in a app without this. I will look at implementing this.
s
Solved! Turns out, the combination of
Modifier.imePadding(),
content padding, and
bringIntoView
doesn't work that well. There are a couple of feature requests related to this: • https://issuetracker.google.com/issues/261909136https://issuetracker.google.com/issues/221252680 The solution for now would be to apply the
Modifier.imePadding()
before making the list scrollable (either as a modifier to the
LazyColumn
or before
Modiifer.verticalScroll()
on the
Column
, whichever's in use). Then, to make sure that
Modifier.imePadding()
also doesn't apply the navigation bar padding twice, consume the system bars padding with
Modifier.consumeWindowInsets()
before
Modifier.imePadding()
. The sample repo has been updated to a working example.