ViewPager手势滑动禁用

拦截触摸事件和触摸事件的返回值改为false即可

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
public class NoScrollViewPager extends ViewPager {
private boolean ENABLE = false;

public NoScrollViewPager(@NonNull Context context) {
super(context);
}

public NoScrollViewPager(@NonNull Context context, @Nullable AttributeSet attrs) {
super(context, attrs);
}

@Override
public boolean onInterceptTouchEvent(MotionEvent ev) {
return ENABLE && super.onInterceptTouchEvent(ev);
}

@Override
public boolean onTouchEvent(MotionEvent ev) {
return ENABLE && super.onTouchEvent(ev);
}
}

Powered by AppBlog.CN     浙ICP备14037229号

Copyright © 2012 - 2020 APP开发技术博客 All Rights Reserved.

访客数 : | 访问量 :