ScrollView 内的 MapView? [英] MapView inside a ScrollView?
本文介绍了ScrollView 内的 MapView?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想在 ScrollView 中有一个 MapView,但是当我尝试滚动地图时,ScrollView 优先!有没有办法在地图内滚动时给 MapView 优先级,否则给 ScrollView?
I would like to have a MapView inside a ScrollView, however when I try to scroll the map, the ScrollView takes priority! Is there a way to give the MapView priority when scrolling inside the map, and the ScrollView otherwise?
谢谢!
推荐答案
我遇到了同样的问题 10 天了,但几分钟前我得到了解决方案!!这是解决方案.我制作了一个自定义 MapView 并像这样覆盖 onTouchEvent().
I have had a same problem for 10 days, but I got a solution a few minutes ago!! Here is the solution. I made a custom MapView and override onTouchEvent() like this.
@Override
public boolean onTouchEvent(MotionEvent ev) {
int action = ev.getAction();
switch (action) {
case MotionEvent.ACTION_DOWN:
// Disallow ScrollView to intercept touch events.
this.getParent().requestDisallowInterceptTouchEvent(true);
break;
case MotionEvent.ACTION_UP:
// Allow ScrollView to intercept touch events.
this.getParent().requestDisallowInterceptTouchEvent(false);
break;
}
// Handle MapView's touch events.
super.onTouchEvent(ev);
return true;
}
这篇关于ScrollView 内的 MapView?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文