Provide initial values for the ViewPropertyAnimator
Using ObjectAnimator
s, optionally with PropertyValuesHolder
s, you can specify start and end values for the animated property:
ObjectAnimator animX = ObjectAnimator.ofFloat(myView, "x", 20f, 50f);
ObjectAnimator animY = ObjectAnimator.ofFloat(myView, "y", 30f, 100f);
AnimatorSet animSetXY = new AnimatorSet();
animSetXY.playTogether(animX, animY);
animSetXY.start();
PropertyValuesHolder pvhX = PropertyValuesHolder.ofFloat("x", 20f, 50f);
PropertyValuesHolder pvhY = PropertyValuesHolder.ofFloat("y", 30f, 100f);
ObjectAnimator.ofPropertyValuesHolder(myView, pvhX, pvyY).start();
How can I achieve the same animation using ViewPropertyAnimator
s? The syntax does not seem to support initial values if they are equal to the values that the view has when the animation starts:
myView.animate().x(50f).y(100f); //Where do I put starting values??
Thank;)
+3
source to share