Animate recomposition (view changes) in Jetpack Compose

Viewed 1428

Is there a way to automatically animate composition changes in a Jetpack Compose @Composable? For instance, if a previously shown widget is removed in a recomposition, can a fade-out animation be applied automatically? I'm thinking something similar to Android View's animateLayoutChanges.

2 Answers

Yes, you can use:

val visible by remember { mutableStateOf(false) }
AnimatedVisibility(visible = visible) {
    // Composables Here 
}

Or for the specific animation you asked for, surround the Composable (s) with CrossFade

Related