Mr.Droid
Mr.Droid

Reputation: 303

Does Android Jetpack Compose support auto animation?

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

Upvotes: 1

Views: 351

Answers (1)

Gabriele Mariotti
Gabriele Mariotti

Reputation: 364694

You can use a side effect

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

or:

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

Upvotes: 1

Related Questions