I want to set colors to my tiles in sequence. This function is called in a for-loop, so its called some times in a very short timewindow.
tile.setImage(R.drawable.blue);
This is the function:
public void setImage(int resId){
Animation fadeInAnimation = AnimationUtils.loadAnimation(this.getContext(), R.animator.fadein);
startAnimation(fadeInAnimation);
setImageResource(resId);
}
and this is the fadein.xml
<alpha
android:duration="1000"
android:fromAlpha="0.0"
android:interpolator="@android:anim/accelerate_interpolator"
android:toAlpha="1.0" />
</set>
I want the animation to start only if the animation before it is done. So I would like the first image to be drawn the first sec and the second image during the second sec, and so on.
BR
Use AnimationListener
especially its method onAnimationEnd(Animation animation)
fadeInAnimation.setAnimationListener(new Animation.AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {
}
@Override
public void onAnimationEnd(Animation animation) {
// CALL next animation
}
@Override
public void onAnimationRepeat(Animation animation) {
}
});`
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.