I am creating an animation with AnimatorSet and when it ends I would like to leave the View where it was.
The code is something like this:
mLastAnimation = new AnimatorSet();
mLastAnimation.playTogether(
ObjectAnimator.ofFloat(mImageView, "scaleX", 1.5f, 1f),
ObjectAnimator.ofFloat(mImageView, "translationY", 40f, 0f));
mLastAnimation.setDuration(3000);
mLastAnimation.addListener(this);
mLastAnimation.start();
// The Activity implements the AnimatorListener interface
@Override
public void onAnimationEnd(Animator animator) {
// Undo the animation changes to the view.
}
EDIT:
I am using the new animation API so setFillAfter() will not work here.
You have to set the properties of the
Viewback to its original values.For example if you translateY 40 pixels forward, you need to translateY 40 pixels backwards. This is because the actual properties of the
Viewhave changed during property animation, not just the way it is rendered.http://developer.android.com/guide/topics/graphics/prop-animation.html#property-vs-view