首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在地图视图android上添加视图叠加

在地图视图android上添加视图叠加
EN

Stack Overflow用户
提问于 2020-01-20 13:36:53
回答 3查看 900关注 0票数 1

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

如何确保覆盖在视图中时阻止地图可控?

EN

回答 3

Stack Overflow用户

回答已采纳

发布于 2020-01-20 13:50:53

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

代码语言:javascript
复制
android:focusable="true"
android:focusableInTouchMode="true"
android:clickable="true"

请记住,您需要将线上方放置在覆盖视图的父布局上

票数 1
EN

Stack Overflow用户

发布于 2020-01-20 13:44:36

您可以通过使覆盖图可单击来完成此操作。将下面的代码添加到覆盖视图的xml中。

android:clickable="true"

票数 0
EN

Stack Overflow用户

发布于 2020-01-20 13:46:07

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

代码语言:javascript
复制
<?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>
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/59817511

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档