我有一個Osmdroid MapView。即使我已經設置了禁用Osmdroid映射中的滾動
mapView.setClickable(false);
mapView.setFocusable(false);
地圖仍然可以移動。有沒有簡單的方法來禁用所有與地圖視圖的交互?
我有一個Osmdroid MapView。即使我已經設置了禁用Osmdroid映射中的滾動
mapView.setClickable(false);
mapView.setFocusable(false);
地圖仍然可以移動。有沒有簡單的方法來禁用所有與地圖視圖的交互?
所有交互我已經找到了解決辦法。您需要通過設置OnTouchListener
直接處理觸摸事件。例如,
public class MapViewLayout extends RelativeLayout {
private MapView mapView;
/**
* @see #setDetachedMode(boolean)
*/
private boolean detachedMode;
// implement initialization of your layout...
private void setUpMapView() {
mapView.setOnTouchListener(new OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
if (detachedMode) {
if (event.getAction() == MotionEvent.ACTION_UP) {
// if you want to fire another event
}
// Is detached mode is active all other touch handler
// should not be invoked, so just return true
return true;
}
return false;
}
});
}
/**
* Sets the detached mode. In detached mode no interactions will be passed to the map, the map
* will be static (no movement, no zooming, etc).
*
* @param detachedMode
*/
public void setDetachedMode(boolean detachedMode) {
this.detachedMode = detachedMode;
}
}
一個簡單的解決方案是不喜歡@Schrieveslaach但的MapView:
mapView.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
return true;
}
});
你找到一個解決辦法? – Schrieveslaach
不幸的不是。 – dominik