Reputation: 10335
Using ObjectAnimator
s, optionally with PropertyValuesHolder
s, it is possible to specify starting and ending 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 with ViewPropertyAnimator
s? The syntax doesn't seem to support starting values, assuming they are equals to the values the view has at animation start:
myView.animate().x(50f).y(100f); //Where do I put starting values??
Thanks ;)
Upvotes: 4
Views: 2568
Reputation: 4725
If you're going to use ViewPropertyAnimator, your Views need to be at the start positions before the animation starts.
Upvotes: 4