处理recycleview与viewpage的滑动冲突

@Override
public boolean dispatchTouchEvent(MotionEvent ev) {
    switch (ev.getAction()) {
        case MotionEvent.ACTION_DOWN:
            y = ev.getY();
            x = ev.getX();
            getParent().requestDisallowInterceptTouchEvent(true);
            break;
        case MotionEvent.ACTION_MOVE:
            if (Math.abs(ev.getX() - x) > Math.abs(ev.getY() - y))
                getParent().requestDisallowInterceptTouchEvent(true);
            else
                getParent().requestDisallowInterceptTouchEvent(false);
            break;
        case MotionEvent.ACTION_UP:
        case MotionEvent.ACTION_CANCEL:
            getParent().requestDisallowInterceptTouchEvent(false);
            break;

        default:
            break;
    }
 
  
重写ViewPage 覆盖以上方法

你可能感兴趣的:(android)