外层竖向ScrollView,里层横向ScrollView滑动冲突的解决方法
实例如下:
publicclassCustomScrollViewextendsScrollView{
privateGestureDetectormGestureDetector;
View.OnTouchListenermGestureListener;
@SuppressWarnings("deprecation")
publicCustomScrollView(Contextcontext,AttributeSetattrs){
super(context,attrs);
mGestureDetector=newGestureDetector(newYScrollDetector());
setFadingEdgeLength(0);
}
//通过手势判断,来判断是否拦截触摸事件。
@Override
publicbooleanonInterceptTouchEvent(MotionEventev){
returnsuper.onInterceptTouchEvent(ev)&&mGestureDetector.onTouchEvent(ev);
}
//Returnfalseifwe'rescrollinginthexdirection
classYScrollDetectorextendsSimpleOnGestureListener{
@Override
publicbooleanonScroll(MotionEvente1,MotionEvente2,floatdistanceX,floatdistanceY){
if(Math.abs(distanceY)>Math.abs(distanceX)){
returntrue;
}
returnfalse;
}
}
}
以上这篇外层竖向ScrollView,里层横向ScrollView滑动冲突的解决方法就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持毛票票。
热门推荐
10 逗比婚礼祝福语简短
11 广西考试祝福语结婚简短
12 浪漫的未来祝福语简短
13 回国了祝福语简短英语
14 姐妹分手了祝福语简短
15 高档的伴娘祝福语简短
16 朋友家住豪宅祝福语简短
17 道士结婚文案祝福语简短
18 中式蛋糕开业祝福语简短