ViewPager intercepts all x-axis onTouch events. How to disable?

后端 未结 4 2031
自闭症患者
自闭症患者 2020-11-29 04:22

Scope

There is a viewpager of two fragments. One of those fragments has a layout witch listens to onTouch changes at X-axis.

Problem

Layout doesn\'t

4条回答
  •  既然无缘
    2020-11-29 04:58

    Similar situation (but not using a ViewPager), putting this in the view that needed the touch event worked for me. Add checks for MotionEvents other than ACTION_MOVE if applicable to your use case.

    @Override
    public boolean onTouchEvent(MotionEvent event) {
        if (event.getAction() == MotionEvent.ACTION_MOVE) {
            this.getParent().requestDisallowInterceptTouchEvent(true);
            return true;
        } else {
            return super.onTouchEvent(event);
        }
    }
    

提交回复
热议问题