Loop with XML animation file?

I created the animation in an XML file. I apply it in text form as follows:

Animation anim = AnimationUtils.loadAnimation(this, R.anim.exit_about); anim.setRepeatMode(Animation.RESTART); anim.setRepeatCount(Animation.INFINITE); v.findViewById(R.id.global_about).startAnimation(anim); // v is my view 

This is done once even if I set the retry counter. Any idea?

+6
android
source share
3 answers

This is strange, I had the same problem, and then I found out about the setRepeatCount and setRepeatMode functions and implemented them, and then they worked fine for me.

here is my code:

 new AnimationUtils(); Animation controller = AnimationUtils.loadAnimation(context, R.anim.flasher); controller.setRepeatCount(-1); controller.setRepeatMode(2); sectionText.startAnimation(controller); 

Perhaps try setRepeatCount your setRepeatCount and setRepeatMode ? Maybe something strange is happening from your point of view?

+2
source share
  Animation anim = new AlphaAnimation(0.0f, 1.0f); anim.setDuration(50); //You can manage the time anim.setStartOffset(20); anim.setRepeatMode(Animation.REVERSE); anim.setRepeatCount(Animation.INFINITE); Yuor_textview.startAnimation(anim); 
0
source share

You need to double your animation as I did below (for Blink animation)

  <set xmlns:android="http://schemas.android.com/apk/res/android" android:duration="1500" android:fillAfter="false" android:repeatMode="reverse"> <alpha android:fromAlpha="1.0" android:toAlpha="0.0" /> // From 0 <alpha android:fromAlpha="0.0" android:toAlpha="1.0"/> // To 1 </set> 
0
source share

All Articles