Search code examples
androidtextview

How to know if a TextView is in animation or not?


upon onClickListener, I am starting an animation on textView (icon)

Animation anim = AnimationUtils
          .loadAnimation(activity.getBaseContext(), R.anim.rotate_refresh);
icon.startAnimation(anim);

on clicking again, I want to check, if the icon is animating (rotating) , keep it that way or else start the animation again.

I want to know how can I check textview is in animation?


Solution

  • Maybe try something like this

    Animation animation = icon.getAnimation();
    if(animation != null && animation.hasStarted() && !animation.hasEnded()){
        //do what you need to do if animating
    }
    else{
        //start animation again
    }