如何以编程方式制作流畅的图像旋转动画?

时间:2013-11-19 15:04:45

标签: android animation

我希望在不使用xml代码动画的情况下平滑地旋转图像(在每个旋转周期不小停止)。

与xml动画中的linear_interpolator类似。

这是我的旋转代码:

    RotateAnimation animRotate;
    AnimationSet animSet;

    animSet = new AnimationSet(true);
    animSet.setInterpolator(new DecelerateInterpolator());
    animSet.setFillAfter(true);
    animSet.setFillEnabled(true);

    final RotateAnimation animRotate = new RotateAnimation(0.0f,360.0f,
        RotateAnimation.RELATIVE_TO_SELF, 0.5f, 
        RotateAnimation.RELATIVE_TO_SELF, 0.5f);

    animRotate.setDuration(10000);
    animRotate.setFillAfter(true);
    animSet.addAnimation(animRotate);
    animSet.setRepeatCount(-1);
    img.startAnimation(animRotate); 

    //at timer
    if (animRotate.hasEnded()) {
    img.startAnimation(animRotate);
    }

0 个答案:

没有答案
相关问题