在RecyclerView中,onInterceptTouchEvent方法是用于拦截触摸事件的,它会在RecyclerView的父布局中调用。当触摸事件触发时,会依次调用onInterceptTouchEvent、onTouchEvent、onInterceptTouchEvent等方法来处理触摸事件。

onInterceptTouchEvent方法只会触发ACTION_DOWN事件,这是因为在RecyclerView的父布局中,只有在ACTION_DOWN事件时才会调用onInterceptTouchEvent方法来判断是否拦截触摸事件,而在ACTION_MOVE和ACTION_UP事件时,会直接调用onTouchEvent方法来处理触摸事件。

如果你想要在onInterceptTouchEvent方法中处理ACTION_MOVE和ACTION_UP事件,可以通过返回true来拦截触摸事件,然后在onTouchEvent方法中处理。例如:

@Override
public boolean onInterceptTouchEvent(MotionEvent e) {
    // 在ACTION_DOWN事件时拦截触摸事件
    if (e.getAction() == MotionEvent.ACTION_DOWN) {
        return true;
    }
    return false;
}

@Override
public boolean onTouchEvent(MotionEvent e) {
    // 在ACTION_MOVE和ACTION_UP事件时处理触摸事件
    if (e.getAction() == MotionEvent.ACTION_MOVE) {
        // 处理滑动操作
        return true;
    } else if (e.getAction() == MotionEvent.ACTION_UP) {
        // 处理触摸松开操作
        return true;
    }
    return super.onTouchEvent(e);
}

这样,当触摸事件触发时,onInterceptTouchEvent方法会拦截ACTION_DOWN事件并返回true,然后onTouchEvent方法会接收到ACTION_MOVE和ACTION_UP事件并进行相应处理

水平滑动recycleView中onInterceptTouchEvent 只会触发ACTION_DOWN事件