滚动型是赶上了谷歌地图触摸事件 [英] ScrollView is catching touch event for google map
问题描述
我有一个包含viewgroups的层次结构,最后一个谷歌地图水平滚动视图。我的问题是,HSV被捕捉左右拖动该的意思为地图。我试过
I have a horizontal scroll view that contains a hierarchy of viewgroups and then finally a google map. My problem is that the HSV is catching the left-right drag that's meant for the map. I've tried
hsv.requestDisallowInterceptTouchEvent(true);
甚至
mapView.getParent().requestDisallowInterceptTouchEvent(true);
但无济于事。有什么我做错了吗?或者你可以建议另一种解决方案?
but to no avail. Is there anything I'm doing wrong here? Or can you suggest another solution?
我想这应该是我原来的问题:我如何实现张贴在这里里面 MapView类解决方案滚动型的。具体来说,我在哪里把code?
I think this should have been my original question: How do I implement the solution posted here Mapview inside a ScrollView. Specifically, where do I put the code?
推荐答案
看来你以正确的方式,但你应该呼吁每个触摸事件requestDisallowInterceptTouchEvent(true)方法(请参阅文档)。尝试<一个href=\"http://stackoverflow.com/questions/8122460/viewpager-intercepts-all-x-axis-ontouch-events-how-to-disable\">this解决方案
It seems you on the right way, but you should call requestDisallowInterceptTouchEvent(true) method on every touch event (see docs). Try this solution
的更新:的
尝试了这一点:
final HorizontalScrollView hsv = ...
final MapView mapView = ...
mapView.setOnTouchListener(new OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
switch (event.getAction()) {
case MotionEvent.ACTION_MOVE:
hsv.requestDisallowInterceptTouchEvent(true);
break;
case MotionEvent.ACTION_UP:
case MotionEvent.ACTION_CANCEL:
hsv.requestDisallowInterceptTouchEvent(false);
break;
}
return mapView.onTouchEvent(event);
}
});
这篇关于滚动型是赶上了谷歌地图触摸事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!