ScrollView is catching touch event for google map

前端 未结 4 1904
醉酒成梦
醉酒成梦 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:24

    You have to create custom MapView. Follow the code snippet provided below

    public class AppMapView extends MapView {
    
        public AppMapView(Context context, AttributeSet attrs) {
            super(context, attrs);
        }
    
        @Override
        public boolean dispatchTouchEvent(MotionEvent ev) {
            switch (ev.getAction()) {
                case MotionEvent.ACTION_UP:
                   System.out.println("unlocked");
                   this.getParent().requestDisallowInterceptTouchEvent(false);
                   break;
    
                case MotionEvent.ACTION_DOWN:
                   System.out.println("locked");
                   this.getParent().requestDisallowInterceptTouchEvent(true);
                   break;
           }
           return super.dispatchTouchEvent(ev);
       }
    }
    

    In XML follow code below:

    
    

提交回复
热议问题