安卓:冲销动画 [英] Android: Reversing an Animation

查看:115
本文介绍了安卓:冲销动画的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有,当它被添加到的布局被动画的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.

有没有办法扭转机器人动画而无需重新编写,并扭转参数?

Is there a way to reverse an animation in android without recoding it and reversing the parameters?

推荐答案

没有,可悲的是,你不能与动画对象做到这一点。 但是你可以用内插器,将逆动画模拟它:

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆