我正在用AnimatorSet创建一个动画,当它结束时,我想把View留在它原来的位置。
代码如下所示:
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.
}编辑:
我使用的是新的动画应用程序接口,所以setFillAfter()在这里不能工作。
发布于 2012-07-26 21:53:10
您必须将View的属性设置回其原始值。
例如,如果向前translateY 40像素,则需要向后translateY 40像素。这是因为View的实际属性在属性动画期间发生了更改,而不仅仅是呈现方式。
http://developer.android.com/guide/topics/graphics/prop-animation.html#property-vs-view
发布于 2013-12-11 15:38:00
如果你使用的是nineoldandroid,有一个叫做reverse的函数。您可以将持续时间设置为0,然后调用reverse来反转动画。
发布于 2017-06-07 19:33:15
使用ObjectAnimator时,您可以简单地设置
android:repeatMode="reverse"https://stackoverflow.com/questions/11670757
复制相似问题