ScrollView is catching touch event for google map

前端 未结 4 1898
醉酒成梦
醉酒成梦 2021-01-18 00:50

I have a horizontal scroll view that contains a hierarchy of viewgroups and then finally a google map. My problem is that the HSV is catching the left-right drag that\'s mea

4条回答
  •  执笔经年
    2021-01-18 01:10

    It seems you on the right way, but you should call requestDisallowInterceptTouchEvent(true) method on every touch event (see docs). Try this solution

    Updated:

    Try this out:

    final HorizontalScrollView hsv = ...
    final MapView mapView = ...
    
    mapView.setOnTouchListener(new OnTouchListener() {
        @Override
        public boolean onTouch(View v, MotionEvent event) {
            switch (event.getAction()) {
                case MotionEvent.ACTION_MOVE:
                    hsv.requestDisallowInterceptTouchEvent(true);
                    break;
                case MotionEvent.ACTION_UP:
                case MotionEvent.ACTION_CANCEL:
                    hsv.requestDisallowInterceptTouchEvent(false);
                    break;
            }
            return mapView.onTouchEvent(event);
        }
    });
    

提交回复
热议问题