2016-04-11 35 views
2

這裏是我的應用程序如何通過佈局禁用谷歌地圖觸摸事件? (機器人)

enter image description here

如果我碰傳說的內容,我仍然可以移動地圖或通過圖例佈局點擊標記的屏幕截圖。這是我的XML

<?xml version="1.0" encoding="utf-8"?> 
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/map_root" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:orientation="vertical"> 

<fragment xmlns:tools="http://schemas.android.com/tools" 
    android:id="@+id/map" 
    android:name="com.google.android.gms.maps.SupportMapFragment" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    tools:context=".activity.MapsActivity" /> 

<LinearLayout 
    android:id="@+id/legend_popover" 
    android:layout_width="120dp" 
    android:layout_height="wrap_content" 
    android:layout_gravity="bottom|right" 
    android:layout_margin="10dp" 
    android:background="@color/white" 
    android:orientation="vertical" 
    android:radius="7dp" 
    android:visibility="gone"> 
... 

我不想禁用整個地圖,我只想禁用圖例彈出窗口上的手勢。謝謝@antonio的答案

+0

yourmap.getUiSettings()。setAllGesturesEnabled(false);或mMapFragment.getView()。setClickable(false); – saeed

+0

檢查此鏈接http://stackoverflow.com/questions/14873288/android-map-api-2-disable-click –

+0

http://stackoverflow.com/a/14893040/3790150 – saeed

回答

4

添加android:clickable="true"legend_popover佈局

5

使用此

mMapFragment.getView()setClickable(假)。

1

另一種體面的方式來達到同樣的。

googleMap.getUiSettings().setAllGesturesEnabled(false);