android:ScrollView滑动冲突问题

在ViewGroup中有个方法叫requestDisallowInterceptTouchEvent(boolean
disallowIntercept),这个方法可以用来控制该ViewGroup是否截断点击事件。

mMapView.getChildAt(0).setOnTouchListener(new View.OnTouchListener() {
            @Override
            public boolean onTouch(View v, MotionEvent event) {
                if(event.getAction() == MotionEvent.ACTION_UP){
                    //允许ScrollView截断点击事件,ScrollView可滑动
                    mScrollView.requestDisallowInterceptTouchEvent(false);
                }else{
                    //不允许ScrollView截断点击事件,点击事件由子View处理
                    mScrollView.requestDisallowInterceptTouchEvent(true);
                }
                return false;
            }
        });

猜你喜欢

转载自blog.csdn.net/xdy1120/article/details/82428637