Travis Griggs
05/09/2024, 6:48 PMimePadding
question. I have a simple layout (I think)
Surface
Column
Row (height fixed)
LazyColumn (weight(1f) and imePadding())
Box (height fixed)
It's shown on the left. When I activate the keyboard, I get what's on the right. I don't understand why I get this big gap between keyboard and bottom of lazy column. It's directly tied to the height of the last fixed box.
Perhaps I'm violating an assumption, that things like imePadding are only supposed to be used on edge adjacent components?Stylianos Gakis
05/09/2024, 7:30 PMStylianos Gakis
05/09/2024, 7:32 PMTravis Griggs
05/09/2024, 8:46 PMTravis Griggs
05/09/2024, 8:46 PMStylianos Gakis
05/09/2024, 8:50 PMTravis Griggs
05/09/2024, 9:12 PMStylianos Gakis
05/09/2024, 9:16 PMimePadding
is just like saying Modifier.padding(bottom = x.dp)
where X is the height of the keyboard atm, that's all it is indeed.Travis Griggs
05/09/2024, 9:46 PMBox
Footer (fixed height and tied to bottom)
Column (full size)
Header
FlexibleList (ie LazyColumn)
Box (imePadding when ime.isVisible and same height as footer when not)
Stylianos Gakis
05/09/2024, 10:03 PMval boxHeight = 50.dp
Surface {
Column {
LazyColumn(Modifier.weight(1f).consumeWindowInsets(PaddingValues(bottom = boxHeight)).imePadding())
Box(Modifier.fillMaxWidth().height(boxHeight))
}
}
to see if this is what you were looking for in the first place.
Since the way that insets are passed down the tree is through modifier locals, if someone above you in the tree has already consumed some insets, this is recorded inside those locals so that the child composable won't also apply those insets, and get double the spacings there.
consumeWindowInsets
allows you to manually inform the downstream modifiers that you know that you've already consumed 50.dp worth of insets towards the bottom, so if the IME is at height 40.dp, then you will not receive anything from imePadding()
. If the IME is at 80.dp height, then since you've already consumed 50.dp from the box, it will only give you the rest 30.dp as paddings.Travis Griggs
05/09/2024, 10:46 PMStylianos Gakis
05/10/2024, 6:57 AM