處理recycleview與viewpage的滑動衝突
阿新 • • 發佈:2018-12-30
@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 覆蓋以上方法