Jovan
Jovan

Reputation: 1741

How can I add button on MapView android

As you can see from the question I need to put some button on mapView, where the app will by presing the button by user, refresh the mapView with current location. I know how to put the button above, under, but how to put on map??? If anyone has some sample code, or some guidance help is appreciated...

Upvotes: 11

Views: 15462

Answers (2)

PedroAGSantos
PedroAGSantos

Reputation: 2346

Hi man search for overlay item is what you need :D here google link http://developer.android.com/resources/tutorials/views/hello-mapview.html

and good sample :D

https://github.com/jgilfelt/android-mapviewballoons

Upvotes: 3

hooked82
hooked82

Reputation: 6376

You'll want to use a RelativeLayout and lay the button over top of the MapView. Just make sure not to place it over the Google logo. Here's a sample XML:

<?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">
    <com.google.android.maps.MapView android:id="@+id/google_maps"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:apiKey="@string/maps_key"/>
    <Button android:id="@+id/googlemaps_select_location"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentBottom="true"
            android:layout_centerHorizontal="true"
            android:text="Select"/>
</RelativeLayout>

Upvotes: 33

Related Questions