在视图中处理Ontouchevent,该视图也响应了Ontouchevent(用于在osmdroid 3.0.2中工作)
-
26-10-2019 - |
题
我目前正在使用osmdroid jar 3.0.1,并且我在a内有一个mapview”可拖动空间”(您可以在屏幕之间滑动的视图)。我的底部有一个条,可以让用户在空间之间滑动,如果触摸事件发生在该区域外,我致电MapView.ontouchevent(event)。
这曾经在3.0.1中效果很好,但是我在osmdroid 3.0.4中尝试过,并且似乎仅适用于垂直运动(我怀疑这与某些触摸斜率设置有关)。
这是我可拖放空间视图的代码。
@Override
public boolean onTouchEvent(MotionEvent event) {
// Check if the current space is the Map space and we are over the map
// difference is the Y value between the top and bottom of the map area.
if (this.mCurrentScreen == 1
&& event.getY() >= topY && event.getY() <= difference){
Log.d(TAG, "touch received inside Map Area");
// Pass the event directly to the mapView.
return mOsmv.onTouchEvent(event);
}
Log.d(TAG, "touch received outside Map Area");
return super.onTouchEvent(event);
}
尽管这很讨厌(该视图必须通过地图的实例),但在版本3.0.1和3.0.2中确实可以正常工作。但是,由于3.0.3它不再起作用。
现在有更好的方法将触摸事件传递给Osmdroid地图吗?
我有一个演示项目,可以说明这个问题。完整的日食项目是 在github上.
您可以更改使用3.0.1或3.0.2 jar的构建路径,并在较大空间内正确地滚动,但更改为3.0.3或3.0.4,任何侧向运动都被忽略了。
任何指导都将不胜感激。
PS,这是osmdroid列表中的交叉帖子。我希望这里还有一些读者。
解决方案
问题是MapView.OntouchEvent被更名为MapView.disPatchTouchEvent,版本3.0.2和3.0.3之间
不隶属于 StackOverflow