ViewPager属于父布局,View属于子布局;

触摸事件是先到父View,再到子View,所以可以让ViewPager取消拦截事件;

SRE实战 互联网时代守护先锋,助力企业售后服务体系运筹帷幄!一键直达领取阿里云限量特价优惠。
public class ComposeViewPager extends ViewPager {
    private String TAG = "ComposeViewPager";
    public ComposeViewPager(Context context) {
        this(context, null);
    }

    public ComposeViewPager(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    @Override
    public boolean onInterceptTouchEvent(MotionEvent ev) {
        final int action = ev.getAction();
        if(action == MotionEvent.ACTION_MOVE){
            return false;
        }
        return super.onInterceptTouchEvent(ev);
    }
}

 

扫码关注我们
微信号:SRE实战
拒绝背锅 运筹帷幄