0
Hi, I’m creating a simple app and I want to make a light stay flashing, so I added the following code:
private void flashLight() {
anim = animate(imgLight).setDuration(speeds[speed]);
anim.alpha(0f).setListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
anim.alpha(1f).setListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
flashLight();
}
});
}
});
}
The code works perfectly on android devices api 11 or more, but in the versions below it does not work, being that animation only runs once. I wish someone would help me with my problem.
Note: I am using the library Nineoldandroids
From now on I thank you.
Silas, why don’t you use the
ObjectAnimatorinstead of theViewPropertyAnimator? It’s much easier to use transitions (0 to 1) and it still has infinite repetition. I don’t usually use theNineOldAndroids, but I usually use theObjectAnimatorof API 11. If you want I can assemble a response using API 11, believing that the migration to theNineOldAndroidsit’s easy.– Wakim