8

我有这个 ObjectAnimator:

    cloudAnim2 = ObjectAnimator.ofFloat(cloud2ImageView, "x",500, 1000);
    cloudAnim2.setDuration(3000);
    cloudAnim2.setRepeatCount(ValueAnimator.INFINITE);
    cloudAnim2.setRepeatMode(ValueAnimator.RESTART);        
    cloudAnim2.start();
    cloudAnim2.addListener(new AnimatorListener() {
        @Override
        public void onAnimationCancel(Animator animation) {}
        @Override
        public void onAnimationEnd(Animator animation) {}
        @Override
        public void onAnimationRepeat(Animator animation) {}
        @Override
        public void onAnimationStart(Animator animation) {}
    });

如您所见,云将从位置 500 开始并动画到位置 1000,然后它会重复动画。

问题是动画在接近完成时变得越来越慢。我的意思是,运动的速度并不总是一样的。

我希望速度总是一样的。如何才能做到这一点?

谢谢

4

1 回答 1

16

默认插值器是AccelerateDecelerateInterpolator,因此您需要手动将其设置为LinearInterpolator.

animation.setInterpolator(new LinearInterpolator());
于 2014-07-07T15:47:02.613 回答