how to implement gesture detector onfling in webview in android
-
27-09-2019 - |
문제
can anybody give example how to implement gesture detector onfling in webview in android
Thanks
해결책
I find this way from somewhere:
To have the gesture detected in a WebView, no need to subclass anything. You just need to add this in your activity:
@Override
public boolean dispatchTouchEvent(MotionEvent e){
super.dispatchTouchEvent(e);
return mGestureDetector.onTouchEvent(e);
}
Where mGestureDetector is initialized as new GestureDetector(this) on your onCreate(). This will intercept all the gesture events, give opportunity to your listener to do whatever your want with it, and send it back to WebView so behaviour won’t be affected.
다른 팁
Done that just today:
private final GestureDetector mGestureDetector = new GestureDetector(new CustomGestureListener());
@Override
public boolean onTouchEvent(MotionEvent event) {
super.onTouchEvent(event);
return mGestureDetector.onTouchEvent(event);
}
private class CustomGestureListener extends GestureDetector.SimpleOnGestureListener {
// override this method: onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY)
}
제휴하지 않습니다 StackOverflow