Home > other >  Does Android Jetpack Compose support auto animation?
Does Android Jetpack Compose support auto animation?

Time:08-25

I want to add an animation to the texts, which will work automatically when the screen is opened

In Android View it can be done easily by just putting this in OnCreate

 val animation = AnimationUtils.loadAnimation(this,R.anim.example)
 text.startAnimation(animation)

How can the same idea work in Compose ?

What I know in Compose is that the state must be changed to run a particular element animation

CodePudding user response:

You can use a side effect

DisposableEffect(Unit) {
    //do something
    onDispose { }
}

or:

LaunchedEffect(Unit) {
    //update the value to start the animation
}
  • Related