Android Animation Flicker

I searched for all stackoverflow posts for animation issue (flicker and sluggish). I didnt find any perfect answer. But I have found the solution for the same, which is as below,

onStart of Animation use,

view_you_want_to_animate.setDrawingCacheEnabled(true);

onEnd of Animation use,

view_you_want_to_animate.setDrawingCacheEnabled(false);

Now my view does not have flicker or sluggish behavior when my view is animating. It works well for me.


@Override
public void onAnimationEnd(Animation animation)
{
    footer.clearAnimation();
}

This worked for me.


I had the same problem and after few days I found the solution ... thanx to:

http://www.mail-archive.com/[email protected]/msg67535.html

I figured out a solution to this problem. The clue came from the fact that when showing the view, everything worked fine. Apparently, when the animation is running, the update that would be forced by the show happens in the background and doesn't cause the flicker. Adding a short animation to the back end of the onAnimationEnd() when we are hiding the view makes the flicker go away.

Here is the new onAndimationEnd() in the working code

  public void onAnimationEnd(Animation animation) {
            animation = new TranslateAnimation(0.0f, 0.0f, 0.0f, 0.0f);
            animation.setDuration(1);
            mPlayer0Panel.startAnimation(animation);
   } 

You shouldn't have to use clearAnimation() on onAnimationEnd().

Try this:

  1. Use setFillBefore(true) and setFillAfter(true) on both animations
  2. Set the correct layout properties when starting and when ending both animations