Is there any guidance for settings insets based on...
# compose
c
Is there any guidance for settings insets based on the keyboard ime for an item in a vertically scrolling column? I'd like the item to appear right above the keyboard when the keyboard surfaces. I've already set my activity to
WindowCompat.setDecorFitsSystemWindows(window, false)
and have tried adding the
Modifier.imePadding
to the TextField I'd like to consume the insets. Unfortunately the way it is consuming them is it is applying the padding to the TextField but not scrolling my Column. Is there a way to have that ime padding associate with my scroll position?
a
Compose
1.4.0-alpha04
just landed with some exciting changes in this area! With the new changes, if the scrolling
Column
or
LazyColumn
itself resizes, it should keep the
TextField
in view as you’d want it to, so that would be my recommendation with those new changes. If you handle the insets internally, either via
contentPadding
, or by setting the IME padding on an element inside the scrolling container, the scrolling container doesn’t know that anything changed, to try to adjust accordingly.
c
That is exciting! I figured there wasn't a magic method you guys made that would propagate/reduce the padding to scroll yet but felt it was worth asking 🙂 . With the new changes, you mention if the Column or LazyColumn itself changes it will keep the composable on screen. I assume for things like insets this must be accompanied by an inset modifier so that the size of those actually changes. For example if I use
Modifier.imePadding()
now on the TextField it applies bottom padding, which would resize the column. But if I don't add that nothing would happen in
1.4.0-alpha04
correct?
a
It depends on the matrix of
WindowCompat.setDecorFitsSystemWindows(window, false)
and
adjustPan
vs
adjustResize
If you are using
WindowCompat.setDecorFitsSystemWindows(window, false)
and
adjustResize
(which leads to the best compatibility across API levels), then yes, you’ll need to apply the
imePadding()
modifier on the scrolling container (or a parent) so that the size of the container changes
c
Gotcha. That makes sense. Looking forward to being able to pull that version in now! Thanks for the quick reply fist bump
z
One thing that is not yet supported is consuming the ime padding by setting
contentPadding
on a lazy column.
c
Chris, let me know how that works out for you. Curious what the right combination is to get that working.
c
It just works now after upgrading to compose 1.4.0-alpha02. I don't do anything special and it automatically adds padding to my scrolling composable when the keyboard is open