在尝试使我的 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/