Website address: https://developer.android.com/reference/android/view/ViewPropertyAnimator.html

###ViewPropertyAnimator advantage: ViewPropertyAnimator provides a simpler way to implement animations when several properties of a View execute in parallel. ViewPropertyAnimator was added in 3.1. ViewPropertyAnimator is similar to ObjectAnimator and can also change the actual value of a View. But ViewPropertyAnimator works only on Views and not on other objects. ViewPropertyAnimator is more efficient and makes the code cleaner and easier to read if you need to animate multiple properties simultaneously.

Commonly used method note
TranslationX (float value), translationY(float value) TranslationX and translationY are the distances of moving value to axis X and axis Y respectively
X (float value), y(float value) For example, x(valueX), y(valueY) : Moves the target View to the coordinate point of (valueX,valueY)
alpha() Set the transparency of the View
rotation() Rotate the View
ScaleX (Float Value), scaleY(float value) For example, scaleX(2f) is used to enlarge the View by 2 times in the X-axis direction, and scaleY is the same
setDuration(long duration) Set the animation duration
setStartDelay(long startDelay) The delay time before the animation starts
setListener(Animator.AnimatorListener listener) The animation listener
setInterpolator(TimeInterpolator interpolator) Time interpolator, used to modify the animation effect
setUpdateListener(ValueAnimator.AnimatorUpdateListener listener) inAPI 19Or above use animated update callbacks
withStartAction(Runnable runnable) Behavior set at the beginning of the animation
withEndAction(Runnable runnable) Behavior set at the end of the animation

### Compare ViewPropertyAnimator with ObjectAnimator

First look at the renderings:

Move the View to the (500F, 500F) coordinates using ViewPropertyAnimator and ObjectAnimator respectively:

1. Multiple ObjectAnimator combinations:

ObjectAnimator animX = ObjectAnimator.ofFloat(myView, "x", 500f);
ObjectAnimator animY = ObjectAnimator.ofFloat(myView, "y", 500f);
AnimatorSet animSetXY = new AnimatorSet();
animSetXY.playTogether(animX, animY);
animSetXY.start();
Copy the code

ObjectAnimator+PropertyValuesHolder

PropertyValuesHolder pvhX = PropertyValuesHolder.ofFloat("x", 500f);
PropertyValuesHolder pvhY = PropertyValuesHolder.ofFloat("y", 500f);
ObjectAnimator.ofPropertyValuesHolder(myView, pvhX, pvyY).start();
Copy the code

3. Use ViewPropertyAnimator

myView.animate().x(500f).y(500f).start();
Copy the code

You can see that using ViewPropertyAnimator in certain situations can greatly simplify the amount of code and readability.