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

Tgo1014

03/22/2022, 3:18 PM
Is there a way to animate from
wrapContentWidth()
to
fillMaxWidth()
without using
animateContentSize()
? When I use this modifier it clips the elevation shadow 😕
f

f.babic

03/22/2022, 3:31 PM
An idea could be that you have a BoxWithConstraints or something similar that gives you info what the maximum width is as well as potentially calculating the "wrap" width of the button. Then animating would still be changing the DP state, but you'd know the values. Alternatively, maybe something with ConstraintLayout, but I haven't used it much. Sorry if I'm not of great help, just sharing ideas!
👍🏽 1
t

Tgo1014

03/22/2022, 3:33 PM
That could work indeed 🤔
f

f.babic

03/22/2022, 3:38 PM
Alternatively something like a Layout composable where you can fetch and store the state of the component size would be a good approach, but it might require more work
t

Tgo1014

03/22/2022, 3:40 PM
Yeah I guess this one is a bit more tricky, the
BoxWithContraints
already give the size if I remember it right
f

f.babic

03/22/2022, 3:43 PM
yeah it gives you the maximum width at least
d

Doris Liu

03/22/2022, 7:24 PM
Have you tried having
animateContentSize
modifier on the child of the
Surface
. If you put the modifier directly on the surface, it clips the Surface, along with the shadow. Setting the modifier on a child should work.
5 Views