zoukankan      html  css  js  c++  java
  • 解决ViewPager与百度地图滑动冲突

    一、问题描述

    ViewPager中嵌套百度地图的时候会出现百度地图滑动冲突。

    二、期望结果:

    滑动地图的时候只有地图滑动,滑动其他区域可以切换viewpager。

    三、解决方法

    自定义viewpager

    package com.aldx.kangdasupervisor.view;
    
    import android.content.Context;
    import android.support.v4.view.ViewPager;
    import android.util.AttributeSet;
    import android.view.View;
    
    import com.aldx.kangdasupervisor.utils.LogUtil;
    
    /**
     * author: chenzheng
     * created on: 2019/7/8 17:45
     * description:
     */
    public class ViewPagerMap extends ViewPager {
        public ViewPagerMap(Context context) {
            super(context);
        }
    
        public ViewPagerMap(Context context, AttributeSet attrs) {
            super(context, attrs);
        }
    
        @Override
        protected boolean canScroll(View v, boolean checkV, int dx, int x, int y) {
            LogUtil.e(v.getClass().getName());
            if (v.getClass().getName().equals("com.baidu.mapapi.map.TextureMapView")) {
                return true;
            }
            return super.canScroll(v, checkV, dx, x, y);
        }
    }

    划重点:

    if (v.getClass().getName().equals("com.baidu.mapapi.map.TextureMapView")) {
                return true;
            }

    此处根据实际地图情况修改,此处仅对百度地图有效,而且我用的是TextureMapView,如果是MapView可以自己修改。

  • 相关阅读:
    fpga不错的源代码下载地址
    iverilog命令选项解释
    altera官方视频教程下载地址
    niosII EDS和QuartusII安装心得体会
    FPGA的JTAG口很脆弱?
    poj2379
    poj2472
    poj2935
    poj3366
    poj1493
  • 原文地址:https://www.cnblogs.com/chenzheng8975/p/11156238.html
Copyright © 2011-2022 走看看