https://kotlinlang.org logo
#compose
Title
# compose
a

Alex

02/16/2023, 11:16 PM
Does anyone know how to disable the window inset animation for
Modifier.imePadding()
?
a

Alex Vanyo

02/16/2023, 11:20 PM
Can I ask why you want to?
a

Alex

02/16/2023, 11:26 PM
To remove the “jumpy” animation when navigating to the second screen (with the text input). I think this jumpyness is caused by the ime animations, as you can see that when I move to the third screen with the keyboard closed, the animation is smoothly sliding.
a

Alex Vanyo

02/16/2023, 11:42 PM
Ah, the search bar sort of bouncing off screen a bit? There isn’t a direct way to disable the animating of
imePadding
and the underlying `ime`value, but there is an imeAnimationTarget value which might be useful to get the effect you’re going for
j

james

02/17/2023, 2:40 AM
I also have a question on
imePadding
related things, if I may ask I noticed
imePadding
and
isImeVisible
were starting out correctly, but if I had the keyboard opened and switched apps (or allowed any other activity to appear really), once I came back to my app,
isImeVisible
is still true, despite the ime not actually being visible, and at this point the
imePadding
value is no longer correct I also did some logging during the opening/closing ime animation, and while the imePadding value was changing, the
imeAnimationSource
and
imeAnimationTarget
values were always
0,0,0,0
, which meant using an expression like
imeAnimationSource != imeAnimationTarget
is not a reliable indicator of animation in progress is there a definitive guide on handling this in a composition whose parent is a Fragment, and the Fragment is hosted in a single Activity? I’ve tried various combinations of adjustResize/setDecorFitsSystemWindows/imePadding modifier, but I cannot get it to work in this specific app — I emphasized this because in my own side projects I have it working perfectly, but I’m not using Activity/Fragment/Composable interop in those.. whereas at my day job we have a large legacy codebase, and I simply cannot get ime data to be reported correctly 😢
a

Alex Vanyo

02/17/2023, 4:41 AM
That definitely sounds like a bug of some sort for the interop case. One thing you could try is setting
consumeWindowInsets
to
false
, which is a property to set on the
ComposeView
that you'd be hosting in a Fragment: https://cs.android.com/androidx/platform/frameworks/support/+/androidx-main:compose/[…]android.kt;l=114;drc=977d53a595ad75ee1693140c84c052cc60bce305 Setting that to
false
passes through the insets to other `View`s, which might be important in your app depending on who is using insets. Also curious what API version(s) you're seeing that on, since how insets propagate changed fairly substantially over time
j

james

02/20/2023, 9:52 PM
thanks for that Alex 💙 I’ll try
consumeWindowInsets = false
when I can find some time to jump back to it and see if that helps the API versions I was using while trying to get insets working were 32 and 33
31 Views