https://kotlinlang.org logo
#compose-android
Title
# compose-android
s

Sergio Moral

12/07/2023, 3:29 PM
Hi guys! I need some help here… 🥹. I have a Fragment where I am showing a text field and below a list with some results when the user is writing on the textfield. The thing is that the list occupy all the height of the screen but the keyboard overlaps some results. The problem is that I cannot resize the activity because of the composition of the activity and I cannot scroll down because is a lazy column inside a column… I have tried some solutions using imepaddings() and trying to get the height of the keyboard to calculate the height of the composable but with no luck, any ideas?
z

Zach Klippenstein (he/him) [MOD]

12/07/2023, 3:33 PM
Can you elaborate on “no luck”? Window insets should be the way to do this. Are you not getting the correct ime window offset at all? And to confirm, you did adjustResize + decorFitsSystemWindows=false?
s

Sergio Moral

12/07/2023, 3:47 PM
Hi @Zach Klippenstein (he/him) [MOD] sorry for my poor explanation. Before explaining what I have tried to do I must say that because of the structure of my Activity I can't use the adjustResize flag to my activity, I know this is a big limitation 🥲. When I said I tried to use imePadding with no luck is that I added a Box whose content is my composable ( a lazyColumn component) and used the Modifier.imePadding() but the component is not resizing or adding any padding. As a desperate solution, I have tried to get the height of the keyboard and tried to calculate the height of my component by subtracting the height of the keyboard… but I guess this is not a very good solution. I have used the windowInsets.ime.getBottom(LocalDensity.current) Maybe I do not understand correctly how to use imePadding and this is the way to achieve it.
This is my situation, for a better understanding
z

Zach Klippenstein (he/him) [MOD]

12/07/2023, 4:05 PM
If your window mode is adjustPan and not adjustResize, then this is impossible to do. The window won’t get the ime insets and instead the system will just slide your root view around to try to keep it visible. If you want any control over this you must use adjustResize.
☝🏾 1
☝️ 3
s

Sergio Moral

12/07/2023, 4:13 PM
I understand… I guess I have a little problem here because is something I tried to avoid. Thank you so much!! 🙂
z

Zach Klippenstein (he/him) [MOD]

12/07/2023, 4:15 PM
Why are you trying to avoid it?
s

Sergio Moral

12/07/2023, 4:19 PM
It is because of how it was created the architecture of the app. This composable is inside a Fragment and that Fragment is on the main activity. That main activity has a custom bottom navigation bar so when I use the adjust resize is shown at the top of the keyboard, this is something that I was trying to avoid because it shouldn't be shown specifically in that view.
z

Zach Klippenstein (he/him) [MOD]

12/11/2023, 4:20 PM
Another way you could do that is to toggle the nav bar visibility based on IME insets
s

Sergio Moral

12/11/2023, 4:59 PM
Yes… this is what I did. I think it is not ideal but is the best way I can do it. Thanks!
z

Zach Klippenstein (he/him) [MOD]

12/11/2023, 5:29 PM
I think that’s a lot better than using a feature that has been recommended against for years and that you have no control over.