moh*_*han 2 android gesture-recognition onfling gesturedetector
任何人都可以举例说明如何在android中的webview中实现手势检测器
谢谢
我从某个地方找到这种方式:
要在WebView中检测到手势,无需子类化任何内容.您只需在活动中添加:
@Override
public boolean dispatchTouchEvent(MotionEvent e){
super.dispatchTouchEvent(e);
return mGestureDetector.onTouchEvent(e);
}
Run Code Online (Sandbox Code Playgroud)
其中mGestureDetector在onCreate()上初始化为新的GestureDetector(this).这将截取所有手势事件,为您的侦听器提供机会,以便随意执行任何操作,并将其发送回WebView,这样行为就不会受到影响.