Chris Johnson
03/21/2022, 8:30 PManimateContentSize
with say an alpha animation? If not, what's the way we should go about this? Say I want to update the alpha alongside the size change for a Text
. Currently it animates the size first and doesn't appear to get any alpha updates. Code in 🧵val alpha by animateFloatAsState(animationSpec = spring(stiffness = Spring.StiffnessMediumLow), targetValue = if (uiState.someState) 1f else .5f)
Text(text = if (uiState.someState) "Send Message" else "", modifier = Modifier.animateContentSize(animationSpec = spring(stiffness = Spring.StiffnessMediumLow))
.alpha(alpha))
Chris Sinco [G]
03/21/2022, 9:10 PMAnimatedContent
would be useful for combining fade + size transform, but @Doris Liu might have other suggestionsDoris Liu
03/21/2022, 10:00 PMAnimatedContent
would be the API to use for this.
animateContentSize
reactively animates the size change after the text has already changed, say from "Send Message" to "". At that point, the animated alpha is applied on an empty text.
AnimatedContent
can help you swap between the old and new text while applying fade and size transform.Chris Johnson
03/21/2022, 10:01 PMAnimatedContent
is powerful.
I was trying to do simultaneous animations via coroutines from this link. https://www.youtube.com/watch?v=Z_T1bVjhMLk&list=PLWz5rJ2EKKc9-BJh8Os6W6iQIp1gtOh2T&index=7▾