gpt4 book ai didi

android - 无法平移或移动 osmdroid map

转载 作者:行者123 更新时间:2023-11-29 14:32:40 26 4
gpt4 key购买 nike

我在示例应用程序中使用 osmdroid map 。可以看到 map ,可以缩放,一切都很好,除了我无法平移/移动 map 。

我的主要 xml 代码是:

 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >

<org.osmdroid.views.MapView
android:id="@+id/mapview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:clickable="true"
android:focusable="true"
android:focusableInTouchMode="true">

</org.osmdroid.views.MapView>

</RelativeLayout>

我的java代码是:

 public class MapTest extends Activity {

private MapView mapView;
private MapController mapController;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_map_test);
mapView = (MapView) findViewById(R.id.mapview);
mapView.setBuiltInZoomControls(false);
mapView.setMultiTouchControls(true);
mapController = this.mapView.getController();
mapController.setZoom(10);
GeoPoint mapCenter = new GeoPoint(17.4467, 78.4667);
mapController.setCenter(mapCenter);
}

}

关于如何启用移动有什么想法吗?

最佳答案

尝试删除:

android:clickable="true"

从您的 MapView。这使得 MapView 消耗触摸事件并且它与 dispatchTouchEvent 方法混淆。您也可以尝试删除可聚焦的内容。

关于android - 无法平移或移动 osmdroid map ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15727055/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com