Wednesday, 24 November 2021

Android Compose - crossfade with sizechange

My Composable has the following structure:

var expandedState by remember { mutableStateOf(false) }

Box(modifier = Modifier.animateContentSize()) {
            Crossfade(targetState = expandedState) { expanded ->
                if (expanded) {
                    ExpanedContent()
                } else {
                    CollapsedContent()
                }
            }
}

The animation from collapsed to expanded state works as expected: both crossfade and size change animation run simultaneously. When collapsing, though. The crossfade animation runs first, after which the size change animation starts.

How can I animate the state in such a way that the crossfade and size change animations run simultaneously for both directions?



from Android Compose - crossfade with sizechange

No comments:

Post a Comment