Saturday, April 16, 2011

Android Animation Bug

After much head bashing I have found a bug in Android. Now I wouldn't be posting it here if I thought it was a big enough bug but I'm sure most of you will encounter it if your using the android.view.animation package. I'm also positive it's a bug because there are tons and tons of animationListener questions on StackOverflow. So there are many variable to make this bug happen so I won't go into the procedures to recreate it. I'm going to keep it Short and Simple and tell you this. If you ever do this:

Animation a = AnimationUtils.loadAnimation(this,R.anim.translate_animation);
a.setAnimationListener(new AnimationListener(){
        @Override
public void onAnimationEnd(Animation animation) {}
        @Override
public void onAnimationRepeat(Animation animation) {}
@Override
public void onAnimationStart(Animation animation) {}
});

And you figure out eventually that any of the onAnimation* methods never get called, then you ran into the bug.

So far the only solution that I found was to make a subclass of the view that you're using and override the onAnimationEnd method with whatever you want to do. Like this.

Shoutout to Matt Quigley. He's a software engineer that works on mobile phones. Follow his blog and his excitement on Android Engineer

No comments:

Post a Comment

Hey There! Please leave a comment, suggestion, or the occasional flame (but only if its informational!)