How to find animation finished game in android


Here is a simple code for animating a web view screen. But the problem is that the screen scrolls to the start of the animation. But I need to apply animation for the current screen ... how can I solve this?

here is my code snippet

if(e1.getX() - e2.getX() > SWIPE_MIN_DISTANCE && Math.abs(velocityX) > SWIPE_THRESHOLD_VELOCITY) {

     mWebView.startAnimation(AnimationUtils.loadAnimation(context, R.anim.page_slide_left_in));  
     mWebView.startAnimation(AnimationUtils.loadAnimation(context,R.anim.page_slide_left_out));

    mWebView.scrollBy(mWebView.getWidth(),0);
}
+5
source share
1 answer

The class android.view.animation.Animation(returns AnimationUtils.loadAnimation) has a nested interface AnimationListenerthat you can use to determine when the animation is complete. In particular, it will be interesting for you to implement onAnimationEnda listener interface method .

Obviously, you also need to call setAnimationListenerin the instance Animationreturned loadAnimation.

+5
source

All Articles