animation.start () o animation.startNow () no se inicia inmediatamente la animación
-
25-09-2019 - |
Pregunta
Tengo un extraño problema - de vez en cuando la animación que deben desaparecer de mi control (ImageButton) no entran en juego inmediatamente. Estoy utilizando la animación desvanecimiento de ocultarlo y luego en myListener en su extremo (onAnimationEnd) Pongo nuevo recurso que la imagen en el botón.
En algún lugar de mi código de aplicación:
Animation a = AnimationUtils.loadAnimation(this,R.anim.fadeout);
a.setAnimationListener(new myListener(location));
buttons[location].setAnimation(a);
a.startNow(); // regardless if its start() or startnNow()
// it will work in most of the cases but not 100% reliable
// I actually can see in debug Log when its late, happens after few more clicks
Luego, en myListener.onAnimationEnd (Animación a):
buttons[location].setImageResource(R.drawable.standard_button);
Parece que hay una regla de que la animación de cada cuarto o quinto no se inicia ...
Gracias por la ayuda!
Solución
añadir
buttons[location].invalidate();
después
a.startNow();
ha fijado mi problema.
Otros consejos
También puede utilizar
buttons[location].startAnimation(a);
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow