Vladimir Kroz
Vladimir Kroz

Reputation: 5367

Android MapView - how to attach additional controls to a MapView in desired position

I need to place additional image button "my current location" to a top right corner of the MapView. Any ideas how to do this?

Making the questions generic:
1) According to MapView documentation it is possible to attach additional view objects to a MapView. How to do this?
2) How to place such additional controls into specific position on MapView?

Upvotes: 0

Views: 1247

Answers (1)

Totic
Totic

Reputation: 1291

The example below adds a button on a mapview, just copy paste it and then move the button to where you like it:

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


<com.google.android.maps.MapView
    android:id="@+id/mapview"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:clickable="true"
    android:apiKey="0y6Hyjz6Kxo-NOV_9KHYF7-ECYeGt99xeyVU3IQ"/>

<Button 
    android:id="@+id/select_3" 
    android:layout_centerHorizontal="true"
    android:layout_marginTop="13dp"
    android:text="Center on Pickup Location" 
    style="@style/BasicButton"
    android:layout_height = "40dp"
    android:layout_width  = "280dp"
    android:onClick="selfSelectCenterLocation">
</Button>


</RelativeLayout>

Upvotes: 2

Related Questions