一、问题描述

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. Flume知识扩展

    1 常见正则表达式语法 元字符 描述 ^ 匹配输入字符串的开始位置.如果设置了RegExp对象的Multiline属性,^也匹配“\n”或“\r”之后的位置. $ 匹配输入字符串的结束位置.如果设置了 ...

  2. LeetCode(数据库)部门最高工资

    ), Salary int, DepartmentId int) )) Truncate table Employee ') ') ') ') Truncate table Department ', ...

  3. 5 Successful Business Models for Web-Based Open-Source Projects

    https://handsontable.com/blog/articles/2016/3/5-successful-business-models-for-web-based-open-source ...

  4. mariadb(mysql)[详解]

    本文链接:https://blog.csdn.net/root__oo7/article/details/82817501 安装: [root@bogon ~]# yum install mariad ...

  5. 为啥用DTO

    0.部分参数对于开发前端的人来说是无意义的,因为传递也没有效果.所以不应该暴露给前端使用. 1.依据现有的类代码,即可方便的构造出DTO对象,而无需重新进行分析. 2.减少请求次数,大大提高效率. 3 ...

  6. 2019.12.09 Random 随机数类

    //导包import java.util.Random;class Demo02 { public static void main(String[] args) { //创建Random对象 Ran ...

  7. Xilinx ISE中使用Synplify综合报错的原因

    在Xilinx ISE中使用Synopsys Synplify 综合比较方便,但有时会出现如下错误: "ERROR:NgdBuild: - logical block ' ' with ty ...

  8. pip崩了, 解决 ModuleNotFoundError: No module named 'pip'.

    今天 在windows下用pip 安装数据库模块pymysql  把pip 弄崩了,直接出现下面的错误.都是红字, 再输入pip install pymysql  ,会报错ModuleNotFound ...

  9. 龙贝格积分(c++)

    用龙贝格算法计算积分 #include <iostream> #include<cmath> #include <iomanip> using namespace  ...

  10. ubuntu之路——day11.7 end-to-end deep learning

    在传统的数据处理系统或学习系统中,有一些工作需要多个步骤进行,但是端到端的学习就是用一个神经网络来代替中间所有的过程. 举个例子,在语音识别中: X(Audio)----------MFCC----- ...