当前位置: 移动技术网 > IT编程>移动开发>Android > 外层竖向ScrollView,里层横向ScrollView滑动冲突的解决方法

外层竖向ScrollView,里层横向ScrollView滑动冲突的解决方法

2019年07月24日  | 移动技术网IT编程  | 我要评论

nittaku,唐僧志txt,浦东金领国际

实例如下:

public class customscrollview extends scrollview {

private gesturedetector mgesturedetector;

view.ontouchlistener mgesturelistener;

@suppresswarnings("deprecation")
public customscrollview(context context,attributeset attrs) {

super(context,attrs);

mgesturedetector= new gesturedetector(new yscrolldetector());

setfadingedgelength(0);

}
//通过手势判断,来判断是否拦截触摸事件。
@override
public boolean onintercepttouchevent(motionevent ev) {
return super.onintercepttouchevent(ev) && mgesturedetector.ontouchevent(ev);
}

// return false if we're scrolling in the x direction

class yscrolldetector extends simpleongesturelistener {

@override
public boolean onscroll(motionevent e1, motionevent e2, float distancex, float distancey) {
if(math.abs(distancey) > math.abs(distancex)) {
return true;
}
return false;
}
}
}

以上这篇外层竖向scrollview,里层横向scrollview滑动冲突的解决方法就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持移动技术网。

如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复

相关文章:

验证码:
移动技术网