Got a small issue with TextField and keyboard over...
# compose
t
Got a small issue with TextField and keyboard overlap. When I click on TextField the content is properly moved above the keyboard. But if if I use imeAction = ImeAction.Next to move to that TextField the content is not moved and stay under the keyboard. Is there some trick to fix this ?
z
Is your activity's adjust resize mode
resize
or
pan
?
m
I believe there’s a bug related to this (i’ve asked this question before). One would think that when you focus on an element the resize of the screen would keep the focused element in the visible area. But this is not working on compose for some reason, and there’s a few hacks around it, provided your TextField is a direct child of the Column you are scrolling.
t
@Zach Klippenstein (he/him) [MOD] It's the default value, when I force resize it does not move at all in all the cases.
@mattinger do you have links for the hacks ?
m
I don’t think so, but here’s what i did:
Copy code
val coroutineScope = rememberCoroutineScope()
    val bringIntoViewRequester = RelocationRequester()

    BasicTextField(
        modifier = modifier
            .onFocusEvent { state ->
                if (state.hasFocus || state.isFocused) {
                    coroutineScope.launch {
                        delay(250L)
                        bringIntoViewRequester.bringIntoView()
                    }
                }
            },
But as i said, it’s not perfect, and when i things like nest the textfield inside a card, it just doesn’t work.
t
Hum yes don't like delay based stuff 😞
So found https://issuetracker.google.com/issues/192043120 and I also have the different behavior between first and second click on textfield. Total mess 😞
c
I actually was having this issue way back when. and I went to try to "fix" it now, and it basically worked without me needing to do anything crazy. maybe compose 1.1.0-rc01 fixed it? See my comment here: https://issuetracker.google.com/issues/192043120
t
Hum will try with lazycolumns using column with scrollable.
c
Spoke too soon. Worked on my emulator. not on my pixel 6. dang. let me know if you find a fix. i will unfortunately start tryinging some of those solutions with "delays" built in 😭
104 Views