Chat, I need your help, maybe I’m missing somethin...
# compose
s
Chat, I need your help, maybe I’m missing something. I thought a simple
animateContentSize
would be sufficient in this case. Here’s the situation: I have a simple Row layout with a main content section and a details panel that slides in from the right. When the details panel appears or disappears, the main content should dynamically resize(shrink when the details show and grow back when they hide). However, I can’t get this behavior to work out of the box. I understand that I could implement a custom
Layout
with manual measuring and positioning to handle the animation, but I was hoping this would work with standard animation modifiers. I also tried using
AnimatedVisibility
, but it didn’t help, it just causes the main content to jump instantly, and the details panel slides into the resulting gap.
1
🦜 1
c
I’d put both items in a row and animate the
weight
modifier
🙌 1
s
I’d like to avoid calculating weight
c
To do animation you’ll need to calculate something. And interpolating a value between 1 and 0.5 is in my opinion the easiest. It’s even in the examples https://developer.android.com/develop/ui/compose/animation/value-based
z
You mentioned trying AnimatedVisibility, theres a variant like RowScope.AnimatedVisibility that uses expand/shrink and fade; did you try that?
❤️ 1
s
thank you, it actually resize the content as I expect
fist bump 1
image.png
And the animation is done without explicitly setting weight or width.
c
that looks so smooth! man. my team definitely under-utilizes animations. compose makes it so simple.
❤️ 1