I have an ImageView that I am animating using a TranslateAnimation. At the end of the animation I want to switch the drawable it is showing. It works but it flickers right before showing the image. I was originally using an AnimationListener and then I followed the examples I found of how to fix this by creating a custom view that extends ImageView and overrides OnAnimationEnd to no avail.
In my activity:
TranslateAnimation = new TranslateAnimation(0, 150, 0, 150);
translateAnimation.setDuration(ANIMATION_DURATION);
btn.setNextImage(buttons.get(2));
btn.startAnimation(3000);
In my custom view I have the following:
protected void onAnimationEnd() {
super.onAnimationEnd();
//this.clearAnimation();
if(_nextImage != null)
this.setImageDrawable(_nextImage);
}
private Drawable _nextImage;
public void setNextImage(Drawable d)
{
_nextImage = d;
}
call this as the first statement in OnAnimationEnd
theViewOnToWhichAnimationIsApplied.clearAnimation();
this should fix it as it solved mine. i did face the same