Which Android Animator to Use?

A guide to deciding which Animator class you need

Photo by Aron Visuals on Unsplash

Android provides us with an Animator class, which consists of a great set of functionality classes allowing us to perform any animations on our view.

https://youtu.be/N_x7SV3I3P0?list=PLmEM3-F7iVMlm936VEVxlITwdn60XJQX0&t=355

Many of them do similar things, which makes it hard for us to choose. Here, I provide a simple guide on selecting according to your needs.

1. Use ViewPropertyAnimator for Simple Animation

If you plan to animate just one view, with basic animations, and you don’t plan to repeat it, just use ViewPropertyAnimator.

txt_animate.animate().apply {
rotationX(3600f)
duration = 5000
interpolator = AccelerateDecelerateInterpolator()
}.start()

Use this approach if you want a most concise animation as you don’t need to instantiate any Animator object yourself.

However, it has limitations:

  • The animation can’t be repeated.
  • You only have an end value to animate to and no start value.
  • Only basic animations are available to the animate

--

--