From https://developer.android.com/jetpack/compose/animation, I learned about AnimatedContent which I can do a simple crossfade as below
fun MyFunction() {
Column {
var currentPage by remember { mutableStateOf("0") }
AnimatedContent(targetState = currentPage,
transitionSpec = {
fadeIn(animationSpec = tween(150)) with
fadeOut(animationSpec = tween(150))
}) { screen -> Text("Page $screen") }
Button(onClick = {
currentPage = (0..10).random().toString()
}) {
Text("Click Me")
}
}
}
However, later, I found there's a Crossfade function as well, and I can just use it.
fun MyFunction() {
Column {
var currentPage by remember { mutableStateOf("0") }
Crossfade(targetState = currentPage) { screen ->
Text("Page $screen")
}
Button(onClick = {
currentPage = (0..10).random().toString()
}) {
Text("Click Me")
}
}
}
It looks like Crossfade is just probably a subset of what AnimateContent can do. Is that correct? If not, what Crossfade can do, that is not covered by AnimateContent?