【问题标题】:Add a view overlay on map view android在地图视图android上添加视图覆盖
【发布时间】:2020-01-20 05:36:53
【问题描述】:

我正在全屏使用来自 Google Map Android SDK 的MapView,但我需要在地图视图上显示另一个透明的完整视图。叠加层按预期显示,但地图可以控制(可以单击标记,可以移动地图),尽管上面有叠加层。

如何确保叠加层防止地图在视野中可控?

【问题讨论】:

    标签: android google-maps-android-api-2 google-maps-android-api-3


    【解决方案1】:

    在您的叠加视图父布局上添加以下内容。

    android:focusable="true"
    android:focusableInTouchMode="true"
    android:clickable="true"
    

    请记住,您需要将上面的行放在覆盖视图的父布局上

    【讨论】:

      【解决方案2】:

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

      android:clickable="true"

      【讨论】:

        【解决方案3】:

        例如我使用下面的代码给页面添加一个按钮

        <?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>
        

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2015-05-25
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          相关资源
          最近更新 更多