gesture issue with mapview in viewpager page

后端 未结 2 1445
南旧
南旧 2020-12-08 10:53

My app\'s main interface is a viewpager where the user just slides the pages horizontally to get to the various pages. One of the pages has a google mapview (pasted below).

2条回答
  •  佛祖请我去吃肉
    2020-12-08 11:33

    Of course there is:

    public class CustomViewPager extends ViewPager {
    
        public CustomViewPager(Context context) {
            super(context);
        }
    
        public CustomViewPager(Context context, AttributeSet attrs) {
            super(context, attrs);
        }
    
        @Override
        protected boolean canScroll(View v, boolean checkV, int dx, int x, int y) {
            if(v instanceof MapView){
                return true;
            }
            return super.canScroll(v, checkV, dx, x, y);
        }
    
    }
    

    This will make the map ignore all the slides inside the map and just care about the slides/draggs outside the map. Hope it helps. (I do this right now for a webview with horizontal scroll)

    EDIT: Forgot to mention that instead of the ViewPager you need to use the CustomViewPager in yout layout.

    
    

提交回复
热议问题