Android-在webview上检测手势
我正在尝试检测webview上的滑动手势 我尝试使用以下功能:Android-在webview上检测手势,android,webview,Android,Webview,我正在尝试检测webview上的滑动手势 我尝试使用以下功能: public boolean onTouchEvent(MotionEvent event) { int action = MotionEventCompat.getActionMasked(event); String DEBUG_TAG = "test"; switch (action) { case (MotionEvent.ACTION_DOWN): Log
public boolean onTouchEvent(MotionEvent event) {
int action = MotionEventCompat.getActionMasked(event);
String DEBUG_TAG = "test";
switch (action) {
case (MotionEvent.ACTION_DOWN):
Log.d(DEBUG_TAG, "Action was DOWN");
return true;
case (MotionEvent.ACTION_MOVE):
Log.d(DEBUG_TAG, "Action was MOVE");
return true;
case (MotionEvent.ACTION_UP):
Log.d(DEBUG_TAG, "Action was UP");
return true;
case (MotionEvent.ACTION_CANCEL):
Log.d(DEBUG_TAG, "Action was CANCEL");
return true;
case (MotionEvent.ACTION_OUTSIDE):
Log.d(DEBUG_TAG, "Movement occurred outside bounds " +
"of current screen element");
return true;
default:
return super.onTouchEvent(event);
}
}
当没有webview时,它会工作并返回正确答案。
但是,当我添加上述内容时,它在webview上不起作用。由于webview必须是全屏的,我想我不能使用上面的功能。
是否有其他方法或我有问题?谁是您实施的触摸事件的侦听器?我是否需要实施侦听器?我只是将函数放在活动中而已。尝试实现一个侦听器,并将其传递给webview中的setOnTouchListener函数