解决ScrollView嵌套百度地图滑动冲突
一、问题描述
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嵌套百度地图滑动冲突的更多相关文章
- 解决ViewPager与百度地图滑动冲突
一.问题描述 ViewPager中嵌套百度地图的时候会出现百度地图滑动冲突. 二.期望结果: 滑动地图的时候只有地图滑动,滑动其他区域可以切换viewpager. 三.解决方法 自定义viewpage ...
- Android——MeasureSpec学习 - 解决ScrollView嵌套ListView和GridView冲突的方法
原文地址:http://blog.csdn.net/yuhailong626/article/details/20639217 在自定义View和ViewGroup的时候,我们经常会遇到int ...
- ScrollView嵌套ListView的滑动冲突问题,是看大神的方法的,作为学习以后用的到
在工作中,曾多次碰到ScrollView嵌套ListView的问题,网上的解决方法有很多种,但是杂而不全.我试过很多种方法,它们各有利弊. 在这里我将会从使用ScrollView嵌套ListView结 ...
- Android 解决ScrollView嵌套RecyclerView导致滑动不流畅的问题
最近做的项目中遇到了ScrollView嵌套RecyclerView,刚写完功能测试,直接卡出翔了,后来通过网上查找资料和 自己的实践,找出了两种方法解决这个问题. 首先来个最简单的方法: recyc ...
- 解决ScrollView嵌套ListView和GridView冲突的方法
本文摘抄自:http://blog.csdn.net/yuhailong626/article/details/20639217 原文地址:http://blog.csdn.net/yuhailong ...
- 解决ScrollView嵌套ViewPager出现的滑动冲突问题
/** * 解决ScrollView嵌套ViewPager出现的滑动冲突问题 */ public class ScrollView1 extends ...
- 解决水平ListView在ScrollView中出现的滑动冲突
解决的问题有两个: 1)实现水平滑动的ListView.重写AdapterView,上代码: package com.liucanwen.horizontallistview.view; imp ...
- 解决ScrollView嵌套RecyclerView的显示及滑动问题
项目中时常需要实现在ScrollView中嵌入一个或多个RecyclerView.这一做法通常会导致如下几个问题 页面滑动卡顿 ScrollView高度显示不正常 RecyclerView内容 ...
- [Android Pro] ScrollView嵌套RecyclerView时滑动出现的卡顿
reference to : http://zhanglu0574.blog.163.com/blog/static/113651073201641853532259/ ScrollView嵌套Rec ...
随机推荐
- MAT022 Foundations of Statistics
MAT022 Foundations of Statistics and Data Science Summative Assessment 2019/20MAT022 Foundations of ...
- django-提交订单
购物车cart.html页面加form表单提交 <form method="post" action="{% url 'order:place' %}"& ...
- LeetCode 990. Satisfiability of Equality Equations
原题链接在这里:https://leetcode.com/problems/satisfiability-of-equality-equations/ 题目: Given an array equat ...
- 微软安全技术Shim
Shim是微软系统中一个小型函数库,用于透明地拦截API调用,修改传递的参数.自身处理操作.或把操作重定向到其他地方.Shim主要用于解决遗留应用程序在新版Windows系统上的兼容性问题,但Shim ...
- k8s 基础概念
摘录自k8s中文社区https://www.kubernetes.org.cn/course kubernetes 源自希腊文,意为舵手,k与s之间是8个字母,所以也叫k8s, docker就像一个个 ...
- SpringBoot中Example的动态条件查询
一.无匹配器的情况: Person person = new Person(); person.setName("test"); Role role = new Role(); r ...
- C博客作业01--分支,顺序结构1
0.展示PTA总分 1.本章学习总结 1.1 学习内容总结 1.学习了if--else,else--if的分支嵌套结构 if (判断条件) { 执行语句1: } else { 执行语句2: }//用来 ...
- 鱼塘钓鱼(fishing)(信息学奥赛一本通 1373)
[问题描述] 有N个鱼塘排成一排(N<100),每个鱼塘中有一定数量的鱼,例如:N=5时,如下表: 即:在第1个鱼塘中钓鱼第1分钟内可钓到10条鱼,第2分钟内只能钓到8条鱼,……,第5分钟以后再 ...
- mysql 添加表字段
mysql> alter table table1 add price ) not null; Query OK, rows affected (0.05 sec) Records: Dupli ...
- h5的复制功能的使用,Clipboard.js的使用,主要是在app里面使用
app中使用,框架用的是vue.js 1.显示要下载这个Clipboard.js插件 package-lock.json里面 "clipboard-polyfill": { &qu ...