android - map View 安卓 :clickable ="false" not working?

标签 android android-mapview

在尝试使我的 map View 不可点击时,我使用了 XML 方法 android:clickable="false",如下所示

   <com.google.android.gms.maps.MapView
    android:id="@+id/map"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    map:cameraZoom="13"
    android:clickable="false"
    map:liteMode="true"
    map:mapType="normal" />

但是,这是行不通的。它仍然可以点击并打开 GoogleMap。

所以我改用代码尝试

    MapView mapView = (MapView) itemView.findViewById(R.id.map);
    //... some other codes
    mapView.setClickable(false);

现在好了。它不再可点击。我觉得 Java 代码可以工作但不能在 XML 上工作,这看起来很奇怪。知道为什么会发生这种情况,或者我遗漏了 XML 中的任何内容?

谢谢!

最佳答案

在你的 public void onMapReady(GoogleMap googleMap) 中试试这个

googleMap.getUiSettings().setAllGesturesEnabled(false);

关于android - map View 安卓 :clickable ="false" not working?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32877282/

相关文章:

android - 在 Android 应用程序和缩放级别中使用 Google map

Android Tabs/Fragments 生命周期

c# - 适用于 Android Xamarin/C# 的谷歌 API key 。 map 仅显示灰色网格

android - 错误 "is not a JSONObject"

android - 如何从我的 AsyncTask 返回一个 ArrayList?

java - 当前位置和搜索位置之间的道路/路线图

Android Mapview 捏合 View 不调用 OnZoomListener

java - map fragment 在恢复时崩溃

android - 在 Android 中从一个 Activity 移动到另一个 Activity 期间的动画转换

android - Android关闭托管游标