ViewPropertyAnimator is special for animating multiple properties

This class enables automatic and optimized animation of select properties on View objects. If only one or two properties on a View object are being animated, then using an ObjectAnimator is fine; the property setters called by ObjectAnimator are well equipped to do the right thing to set the property and invalidate the view appropriately. But if several properties are animated simultaneously, or if you just want a more convenient syntax to animate a specific property, then ViewPropertyAnimator might be more well-suited to the task.
This class may provide better performance for several simultaneous animations, because it will optimize invalidate calls to take place only once for several properties instead of each animated property independently causing its own invalidation. Also, the syntax of using this class could be easier to use because the caller need only tell the View object which property to animate, and the value to animate either to or by, and this class handles the details of configuring the underlying Animator class and starting it. Refer to ViewPropertyAnimator in Android Developer for more details.

However there is some major drawbacks. When we should animate several views at the same time or not only views but other objects, this approach is not good enough. Refer to Animation several views simultaneously.

Usage:
the animate() function of a view returns an instance of ViewPropertyAnimator. Son we can run an animation by some code similar below.

myView.animate().scaleX(0.5f).scaleY(0.3f).setDuration(2000);

The animation starts automatically and a start() function is not needed.

Comments