Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 216
Malleswar Chinta Avatar asked Mar 25 '15 08:03

Malleswar Chinta


People also ask

How do you animate Textview?

To start the animation we need to call the startAnimation() function on the UI element as shown in the snippet below: sampleTextView. startAnimation(animation); Here we perform the animation on a textview component by passing the type of Animation as the parameter.

What is Android animation?

Animations can add visual cues that notify users about what's going on in your app. They are especially useful when the UI changes state, such as when new content loads or new actions become available. Animations also add a polished look to your app, which gives it a higher quality look and feel.

What is Crossfade in Android?

Crossfade animations (also know as dissolve) gradually fade out one UI component while simultaneously fading in another. This animation is useful for situations where you want to switch content or views in your app. Crossfades are very subtle and short but offer a fluid transition from one screen to the next.


2 Answers

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
}
like image 148
MikeIsrael Avatar answered Oct 20 '22 18:10

MikeIsrael


This line will let you know if the TextView is animated

Animation animation=textView.getAnimation();
like image 6
Arun Avatar answered Oct 20 '22 19:10

Arun