Android WebView滑动翻页

函数原型:
android.view.GestureDetector.OnGestureListener.onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY)

Notified of a fling event when it occurs with the initial on down MotionEvent and the matching up MotionEvent. The calculated velocity is supplied along the x and y axis in pixels per second.

Parameters
e1	The first down motion event that started the fling.
e2	The move motion event that triggered the current onFling.
velocityX	The velocity of this fling measured in pixels per second along the x axis.
velocityY	The velocity of this fling measured in pixels per second along the y axis.
Returns
true if the event is consumed, else false

	private GestureDetector gestureDetector;
	private WebView webView01;
	gestureDetector = new GestureDetector(this, this);

	@Override
	public boolean onTouch(View v, MotionEvent event) {
                //转发手势事件
		gestureDetector.onTouchEvent(event);
		return false;
	}

	@Override
	public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX,
			float velocityY) {

		float vx = Math.abs(velocityX);
		float vy = Math.abs(velocityY);
		
		//处理左右滑屏,实现翻页效果
		if(vx > vy) {
			if(velocityX > 0) {
				if(webView01.canGoBack()) {
					webView01.goBack();
					int width = webView01.getWidth();
					Animation translateAnimation = new TranslateAnimation(0, width, 0, 0);
					translateAnimation.setDuration(500);
					webView01.setAnimation(translateAnimation);
				}
			} else if(velocityX < 0) {
				if(webView01.canGoForward()) {
					webView01.goForward();
					int width = webView01.getWidth();
					Animation translateAnimation = new TranslateAnimation(0, -width, 0, 0);
					translateAnimation.setDuration(500);
					webView01.setAnimation(translateAnimation);
				}
			}
		}
		return false;
	}