Has anyone had any luck creating a custom `Arrange...
# compose
z
Has anyone had any luck creating a custom
Arrangement.VerticalOrHorizontal
where the spacing between items is animated in response to their existence (and size being > 0)? My goal is to create a Column where theres always one element, and when others show up or are hidden (AnimatedVisibility); the spacing between them is animated in/out too.
s
I've achieved this by placing the padding inside of the AnimatedVisibility content block, rather than in the parent Column
z
I'm trying to avoid having to do that everywhere, if possible! The composable with it is used in a lot of places.
đŸ’¯ 1
e
@Zoltan Demant what have you tried? I imagine this should just work if you create a wrapping arrangement and update the
space
property to be based on an updated state of another arrangement’s
space
. Then you can read & animate the actual spacing using animatable.
z
Not at my computer right now so I don't have the code, but it's more or less a composable to create the arrangement, storing animatables, one for each spacer. The arrangement then updates the item heights which trigger the animations. I've more or less tried to copy what spacedBy does, just using animated values. But. It doesn't quite work, either there's no spacing, or it's misplaced.
e
Okay now I understand what you mean, I thought you meant the spacing across all items is animated but this is different, you want the spacing before or after each individual item to be animated. Not sure its possible as a custom arrangement
z
Yes exactly! I can do it with a custom layout as well, but it would be awesome to just use column so that outside usage just sees it as yet another column (which it technically is).