2010-09-16 20 views
6

Creé una animación en un archivo xml. lo aplico en una TextView como esto:Looping con un archivo de animación XML?

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 

Esto se ejecuta una vez, incluso si fijo un número de repetición. ¿Alguna idea?

+0

encontré la solución en otra respuesta. Funciona para mi. ¡Aclamaciones! https://stackoverflow.com/a/4844448/6049708 –

Respuesta

2

Esto es extraño, tuve el mismo problema, y ​​luego me enteré de las funciones setRepeatCount y setRepeatMode, y las implementé, y luego me funcionaron bien.

aquí está mi código:

new AnimationUtils(); 

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

tratan Tal vez invirtiendo el orden de sus setRepeatCount y setRepeatMode funciones? Tal vez hay algo raro pasando con su punto de vista?

+0

Cambiar el orden ni reemplazar las constantes por "-1, 2" me lo resolvió. Agrego el anim a ImageView y TextView programmatically de Android 3.2 a 4.x. –

0
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

hay que hacer doble su animación como lo hice a continuación (Para parpadeo de Animación)

<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> 
Cuestiones relacionadas