一、问题描述

scrollview中嵌套百度地图时会出现滑动冲突,地图无法滑动的情况。

二、期望结果

焦点在地图上时,只有地图移动,焦点在地图外部时,可以滑动scrollview。

三、解决方法

自定义包裹地图的容器

package com.aldx.kangdasupervisor.view;

import android.content.Context;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.widget.LinearLayout; /**
* author: chenzheng
* created on: 2019/7/9 11:20
* description:
*/
public class BaiduMapContainer extends LinearLayout {
private MyScrollview scrollView;
public BaiduMapContainer(Context context) {
super(context);
}
public BaiduMapContainer(Context context, AttributeSet attrs) {
super(context, attrs);
}
public void setScrollView(MyScrollview scrollView) {
this.scrollView = scrollView;
}
@Override
public boolean onInterceptTouchEvent(MotionEvent ev) {
if (ev.getAction() == MotionEvent.ACTION_UP) {
scrollView.requestDisallowInterceptTouchEvent(false);
} else {
scrollView.requestDisallowInterceptTouchEvent(true);
}
return false;
}
@Override
public boolean onTouchEvent(MotionEvent event) {
return true;
}
}

自定义scrollview

package com.aldx.kangdasupervisor.view;

import android.content.Context;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.view.ViewConfiguration;
import android.widget.ScrollView; /**
* author: chenzheng
* created on: 2017/7/5 8:46
* description:
*/ public class MyScrollview extends ScrollView {
private int downX;
private int downY;
private int mTouchSlop; public MyScrollview(Context context) {
super(context);
mTouchSlop = ViewConfiguration.get(context).getScaledTouchSlop();
} public MyScrollview(Context context, AttributeSet attrs) {
super(context, attrs);
mTouchSlop = ViewConfiguration.get(context).getScaledTouchSlop();
} public MyScrollview(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
mTouchSlop = ViewConfiguration.get(context).getScaledTouchSlop();
} @Override
public boolean onInterceptTouchEvent(MotionEvent e) {
int action = e.getAction();
switch (action) {
case MotionEvent.ACTION_DOWN:
downX = (int) e.getRawX();
downY = (int) e.getRawY();
break;
case MotionEvent.ACTION_MOVE:
int moveY = (int) e.getRawY();
if (Math.abs(moveY - downY) > mTouchSlop) {
return true;
}
}
return super.onInterceptTouchEvent(e);
}
}

绑定scrollview与MapView

bannerContainer.setScrollView(myScrollview);

布局

<com.aldx.kangdasupervisor.view.BaiduMapContainer
android:id="@+id/bannerContainer"
android:layout_width="match_parent"
android:layout_height="wrap_content"> <com.baidu.mapapi.map.TextureMapView
android:id="@+id/bmapView"
android:layout_width="match_parent"
android:layout_height="200dp"
android:clickable="true" /> </com.aldx.kangdasupervisor.view.BaiduMapContainer>

解决ScrollView嵌套百度地图滑动冲突的更多相关文章

  1. 解决ViewPager与百度地图滑动冲突

    一.问题描述 ViewPager中嵌套百度地图的时候会出现百度地图滑动冲突. 二.期望结果: 滑动地图的时候只有地图滑动,滑动其他区域可以切换viewpager. 三.解决方法 自定义viewpage ...

  2. Android——MeasureSpec学习 - 解决ScrollView嵌套ListView和GridView冲突的方法

      原文地址:http://blog.csdn.net/yuhailong626/article/details/20639217   在自定义View和ViewGroup的时候,我们经常会遇到int ...

  3. ScrollView嵌套ListView的滑动冲突问题,是看大神的方法的,作为学习以后用的到

    在工作中,曾多次碰到ScrollView嵌套ListView的问题,网上的解决方法有很多种,但是杂而不全.我试过很多种方法,它们各有利弊. 在这里我将会从使用ScrollView嵌套ListView结 ...

  4. Android 解决ScrollView嵌套RecyclerView导致滑动不流畅的问题

    最近做的项目中遇到了ScrollView嵌套RecyclerView,刚写完功能测试,直接卡出翔了,后来通过网上查找资料和 自己的实践,找出了两种方法解决这个问题. 首先来个最简单的方法: recyc ...

  5. 解决ScrollView嵌套ListView和GridView冲突的方法

    本文摘抄自:http://blog.csdn.net/yuhailong626/article/details/20639217 原文地址:http://blog.csdn.net/yuhailong ...

  6. 解决ScrollView嵌套ViewPager出现的滑动冲突问题

    /**       *         解决ScrollView嵌套ViewPager出现的滑动冲突问题       */       public class ScrollView1 extends ...

  7. 解决水平ListView在ScrollView中出现的滑动冲突

      解决的问题有两个:  1)实现水平滑动的ListView.重写AdapterView,上代码: package com.liucanwen.horizontallistview.view; imp ...

  8. 解决ScrollView嵌套RecyclerView的显示及滑动问题

        项目中时常需要实现在ScrollView中嵌入一个或多个RecyclerView.这一做法通常会导致如下几个问题 页面滑动卡顿 ScrollView高度显示不正常 RecyclerView内容 ...

  9. [Android Pro] ScrollView嵌套RecyclerView时滑动出现的卡顿

    reference to : http://zhanglu0574.blog.163.com/blog/static/113651073201641853532259/ ScrollView嵌套Rec ...

随机推荐

  1. 大数据开发keras框架环境配置小结

    系统安装问题 win10+ubuntu16.04 在win10在需要security boot设置成disable,否则安装完后无法设置启动项. 安装完ubuntu重启,系统会直接进入win10,需要 ...

  2. HttpContext对象下的属性Application、Cache、Request、Response、Server、Session、User

    概述: HttpContext封装关于单个HTTP请求的所有HTTP特定信息. HttpContext基于HttpApplication的处理管道,由于HttpContext对象贯穿整个处理过程,所以 ...

  3. hexo与github page搭建博客

    安装 npm i hexo-cli -g hexo init blog cd blog npm install hexo server 发布hexo到github page npm i hexo-de ...

  4. STM32 IAP程序 源码 和测试代码 有详细的中文注释

    http://bbs.21ic.com/forum.php?mod=viewthread&tid=588265&reltid=624002&pre_pos=2&ext= ...

  5. JavaScript的深入理解(1)

    (1)什么是JavaScript? JavaScript是一种专为与网页交互而设计的脚本语言,由三个部分组成:(1).ECMAScript :提供核心语言功能.(2).文档对象模型(DOM):提供访问 ...

  6. rhcsa备战笔记

    笔记全部手打 转载请加原文链接 0)重置密码开机按e 找到linux16行 rd.break console=tty0  ctrl+xmount -o remount,rw /sysrootchroo ...

  7. B/S结构与C/S结构测试区别

    B/S结构与C/S结构 B/S结构是浏览器/服务器结构,应用软件的业务逻辑完全在服务器端实现,客户端只需要通过浏览器完成浏览.查询.输入等简单操作. C/S结构是客户端/浏览器结构,客户端具有一定的数 ...

  8. 使用terraform v0.12 生成gitlab repo 创建部署tf 文件

      以前写过一个使用模版引擎+ rest 接口的模式,生成tf 文件,v0.12 直接提供了方便的json 处理函数 我们可以直接结合http 以及templatefile providers 方便的 ...

  9. CSPS_109

    T1 状压+位运算解决 T2 打完暴力后感到了迷茫.. 不过看这张表里1的数目占了一半之多,应该合法情况挺多的 拿出了从未用过的srand(time(0)); 结果撞上正解了(笑)(rp--) 现在$ ...

  10. 从一道题浅说 JavaScript 的事件循环

    最近看到这样一道有关事件循环的前端面试题: //请写出输出内容 async function async1() { console.log('async1 start'); await async2( ...