Android 在地图视图上添加视图覆盖

Android 在地图视图上添加视图覆盖,android,google-maps-android-api-2,google-maps-android-api-3,Android,Google Maps Android Api 2,Google Maps Android Api 3,我正在全屏使用Google Map Android SDK中的MapView,但我需要在MapView上显示另一个透明的全屏视图。覆盖显示如预期的那样,但是,尽管覆盖在地图上,但可以控制地图(可以单击标记,可以移动地图) 如何确保覆盖图在视图中不受控制?您可以通过使覆盖图可单击来实现这一点。将以下代码添加到覆盖视图的xml android:clickable=“true”例如,我使用以下代码向页面添加按钮 <?xml version="1.0" encoding="utf-8"?>

我正在全屏使用Google Map Android SDK中的
MapView
,但我需要在MapView上显示另一个透明的全屏视图。覆盖显示如预期的那样,但是,尽管覆盖在地图上,但可以控制地图(可以单击标记,可以移动地图)


如何确保覆盖图在视图中不受控制?

您可以通过使覆盖图可单击来实现这一点。将以下代码添加到覆盖视图的
xml


android:clickable=“true”

例如,我使用以下代码向页面添加按钮

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

<fragment
    android:id="@+id/location_map"
    class="com.google.android.gms.maps.SupportMapFragment"
    android:layout_alignParentTop="true"
    android:layout_alignParentStart="true"
    android:layout_width="match_parent"
    android:layout_height="match_parent" />

<Button
    android:id="@+id/button1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:background="#359c5e"
    android:layout_alignParentTop="true"
    android:layout_alignParentEnd="true"
    android:padding="8dp"
    android:layout_margin="5dp"
    android:text="@string/go"
    android:textColor="#ffffff" />

</RelativeLayout>

在覆盖视图父布局上添加以下内容

android:focusable="true"
android:focusableInTouchMode="true"
android:clickable="true"
请记住,您需要在覆盖视图的父布局上放置线的上方