Daniele Segato
11/25/2022, 6:50 PMLayout
with custom measurement and placement. I want to animate elements inside it, specifically when a parameter change I want one item to move and scale.
I first approached this like this:
val dynamicSize = animateFloatAsState(
targetValue = if (condition) .3f else 1f
)
Layout(
content = {
Box(
modifier = Modifier
.fillMaxSize(dynamicSize.value)
)
// ...
and than I kept the size to full inside my measurement... But now I actually need to decide the scaling in my layout measure logic.
Should I remove the fillMaxSize()
, have an animateFloatAsState()
outside the Layout
and use the 0f
--> 1f
inside the measure block to control the size with the constraints?
Is this an efficient way of handling animations with Layout
? I'm worried that i can become very complex in this layout to work with all the possibles options for animations.
I'm open to suggestions / code examples / anything that can show me how people handle this kind of things. Thanks.Daniele Segato
11/25/2022, 10:07 PMDoris Liu
11/29/2022, 12:21 AMfillMaxSize(friction)
, unless you intend to have the scaled content influence the placement/size of the other content.Daniele Segato
12/01/2022, 12:04 PM