5


Here is a simple code to animate webview screen. But the problem is, the screen get scrolled before the animation take place..but i need apply animation for current screen... how can i solve this?

here is my piece of Code

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);
}
vnshetty
  • 20,051
  • 23
  • 64
  • 102

1 Answers1

5

The android.view.animation.Animation class (returned by AnimationUtils.loadAnimation has a nested interface called AnimationListener which you can use to determine when an animation has completed. Specifically, you'd be interested in implementing the onAnimationEnd method of the listener interface.

Obviously, you'd also have to call setAnimationListener on the Animation instance returned by loadAnimation.

slyfox
  • 950
  • 9
  • 22
  • @vnshetty There's also the option of overriding the `View` class' `onAnimationEnd` method, as described in [this answer](http://stackoverflow.com/questions/4750939/android-animation-is-not-finished-in-onanimationend/5110476#5110476). Personally, I've only used the method in my answer to detect the end of an animation, so I'm not aware of any other methods without having to go search for them. – slyfox May 05 '11 at 18:31