Skip to content Skip to sidebar Skip to footer

Android Valueanimator Pauses During Repeat

So I'm using a ValueAnimator to animate a stick figure's limbs from one position to another, in an infinite loop, or at least until the animation is stopped. My problem is that whe

Solution 1:

for Animation, you can configure the interpolator as LinearInterpolator in the animation file :

android:interpolator="@android:anim/linear_interpolator"

for Animator, LinearInterpolator also work for me, I had a rotate animator, do 360 degrees rotation and repeat infinite:

publicclassRotateAnimator {
    privatefloat mDegrees;
    private ObjectAnimator mAnim;

    privateRotateAnimator() {
        mAnim = ObjectAnimator.ofFloat(this, "degrees", 360);
        mAnim.setInterpolator(new LinearInterpolator());
        mAnim.setRepeatCount(ValueAnimator.INFINITE);
        mAnim.setRepeatMode(ValueAnimator.INFINITE);
        mAnim.setEvaluator(new FloatEvaluator());
        mAnim.setDuration(2000);
        mAnim.start();
    }

    publicfloatgetDegrees() {
        return mDegrees;
    }

    publicvoidsetDegrees(float degrees) {
        this.mDegrees = degrees;
        // invalidate the view so it can redraw itself
        invalidate();
    }

}

that way solved my problem, if you couldn't find another solution, hope this can help you, good luck.

Post a Comment for "Android Valueanimator Pauses During Repeat"