反转动画 [英] Reversing an Animation
本文介绍了反转动画的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个ImageView,当将它添加到布局中时会对其进行动画处理。
删除后,我想反转相同的动画。
I have an ImageView that gets animated when it is added to a layout. When it is removed, I want to reverse the same animation.
有没有一种方法可以在android中反转动画而不对其进行编码和反转参数?
Is there a way to reverse an animation in android without recoding it and reversing the parameters?
推荐答案
不,遗憾的是,您不能使用Animation对象来做到这一点。
但是您可以使用将反转动画的插值器对其进行仿真:
No, sadly you cannot do it with the Animation object. But you can simulate it using an interpolator that will inverse the animation:
package com.example.android;
import android.view.animation.Interpolator;
public class ReverseInterpolator implements Interpolator {
@Override
public float getInterpolation(float paramFloat) {
return Math.abs(paramFloat -1f);
}
}
然后在动画上可以设置新的插值器:
Then on your animation you can set your new interpolator:
myAnimation.setInterpolator(new ReverseInterpolator());
这篇关于反转动画的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文