Alessandro Lorusso
Alessandro Lorusso

Reputation: 357

How can I animate a vector drawable to rotate a few times with Kotlin?

I'm very new to animation in Android and I've been trying to rotate a vector drawable as kind of a loading animation. I have the drawable in its own Fragment and I want to rotate it a few times and then switch fragments. Most of what I've read online is very old and I'm trying to figure out the most up to date standard way to do this.

Upvotes: 0

Views: 258

Answers (1)

appersiano
appersiano

Reputation: 2770

simple and clean solution:

imgView.animate()
        .rotation(360f * 4) //if you want a complete rotation x times
        .setDuration(5000)
        .withEndAction {
            Toast.makeText(this@MainActivity, "GO TO FRAGMENT B", Toast.LENGTH_SHORT).show()
        }
        .start()

Upvotes: 1

Related Questions