One of the most painful UX issues to get right (for me at least, maybe it's just because I'm bad at building mobile apps!) is making sure my layout reacts to whether the keyboard is visible or not. In React Native we have the KeyboardAvoidingView (which works, kind of, if you poke it just right). Is there anything similar for Compose yet? If not, has anyone found a good solution for building a layout which resizes based on whether the keyboard is visible or not?
My use-case is basically a chat-style interface: I'm trying to build a chat history (inside a
VerticalScroller
) which takes up most of the screen, with a
Column
wrapping the
VerticalScroller
and a
TextField
element below it, but have the whole thing take up the entire view port that isn't covered by the keyboard (e.g. if the keyboard is hidden, it'll take up the whole height - if the keyboard is shown, it'll reduce in height to take up all the available height except what the keyboard is covering).
g
grandstaish
06/19/2020, 2:10 PM
Not compose-specific, but could you just have the activity resize when the soft input is shown using
-like composable that works with the new IME controller APIs in android 11. I think it would be pretty straightforward to build
r
rophuine
06/20/2020, 5:38 AM
Thanks for the suggestions - I've gone with the adjustResize suggestion. It's not quite perfect but I'll tinker further once I get to the polishing stage 🙂