idrisadetunmbi
idrisadetunmbi

Reputation: 1027

Add a view overlay on map view android

I am using the MapView from the Google Map Android SDK in full screen, but I have a requirement to display another transparent full view over the mapview. The overlay displays as expected, however, the map can be controlled (markers can be clicked, map can be moved) despite the overlay being on it.

How can I ensure the overlay prevents the map from being controllable when in view?

Upvotes: 1

Views: 1617

Answers (3)

IamAjijul
IamAjijul

Reputation: 126

Add following on your overlay view parent layout.

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

Remember you need to place above line on parent layout of overlay view

Upvotes: 1

mojtaba
mojtaba

Reputation: 94

For example I use the following code to add a button to the page

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

Upvotes: 0

Sajith
Sajith

Reputation: 771

You can do this by making your overlay clickable. Add below code to the xml of your overlayview.

android:clickable="true"

Upvotes: 0

Related Questions