Travis Griggs
04/27/2023, 10:22 PMTravis Griggs
04/27/2023, 10:25 PMStylianos Gakis
04/28/2023, 10:39 AMWindowCompat.setDecorFitsSystemWindows(window, false)
on your activity?Stylianos Gakis
04/28/2023, 11:26 AM.imePadding()
with for example .padding(bottom = 300.dp)
you’ll see that you simply get this pic as a resultStylianos Gakis
04/28/2023, 11:31 AMDivider(
modifier = Modifier.height(40.dp + with(density) { WindowInsets.ime.getBottom(this).toDp() }),
color = Color.Red,
)
will result in this picStylianos Gakis
04/28/2023, 11:39 AMDivider(
modifier = Modifier
.height(
40.dp + with(density) { WindowInsets.ime.exclude(WindowInsets(bottom = 80.dp)).getBottom(this).toDp() },
),
color = Color.Red,
)
Definitely some room for improvement in here, especially this hard-coded 80dp may be brittle to changes but if you know what these two dividers height really is you can be sure you’re not doing something wrong. And in general, you can take this information and do what you are trying to do I think.Stylianos Gakis
04/28/2023, 12:19 PMdensity
is just val density = LocalDensity.current
Travis Griggs
04/28/2023, 5:58 PMWindowCompat.setDecorFitsSystemWindows(window, false)
, I have that turned on in my Activity. But I've just been experimenting with this in a single file with an @Preview and then hitting the little "Run Preview" option at the top right of the preview screen in split mode. I'm unclear of how that option conditions the activity wrapping around the preview screen.Travis Griggs
04/28/2023, 6:00 PMTravis Griggs
04/28/2023, 6:05 PMStylianos Gakis
04/28/2023, 6:16 PMTravis Griggs
04/28/2023, 6:33 PMTravis Griggs
04/28/2023, 6:39 PMadjustNothing
, then it would behave as expected, without having to back out/accomodate the movement caused by the resize. Unfortunately, that makes no real difference on this S20. It behaves as if the two modes are the same. Or if it is different, it's not apparent how they're differing.Stylianos Gakis
04/28/2023, 7:32 PMWindowInsets.ime.getBottom(this).toDp()
is literally the DP value of how hight the IME is. So your divider then is starting from the bottom and it goes as high as it does because:
+ 40dp higher than the bottom since there is another divider down there
+ 40dp more since it has the height of 40dp itself
+ the IME height, however much that is.
So it ends up being as high as the IME is +80dp, and with that you get the image here https://kotlinlang.slack.com/archives/C04TPPEQKEJ/p1682681469774739?thread_ts=1682634176.948959&cid=C04TPPEQKEJ
Hence consuming 80dp of that from the insets fixes this and makes it go exactly above the IME.Alex Vanyo
04/28/2023, 8:25 PM@Preview
on a device, it embeds it in this `PreviewActivity`: https://cs.android.com/androidx/platform/frameworks/support/+/androidx-main:compose/[…]Activity.kt;l=49;drc=66e8c2d5eaf727c44779ddb7bc4e0298e4d7b1d0
For most composables that’s fine, but yeah when behavior is dependent on window flags it can be a bit confusing, since that activity won’t have windowSoftInputMode
adjustments or WindowCompat
calls.Travis Griggs
04/28/2023, 11:00 PMTravis Griggs
04/28/2023, 11:00 PM