2011-08-25 102 views
10

正如你可以從問題中看到的,我需要在mapView上放置一些按鈕,其中應用程序將按用戶按下按鈕,使用當前位置刷新mapView。 我知道如何把上面的按鈕,下,但如何把地圖? 如果任何人有一些示例代碼,或一些指導幫助表示讚賞...如何添加MapView上的按鈕android

回答

29

你要使用的RelativeLayout及以上的MapView的頂部放置按鈕。請確保不要將其放在Google徽標上。下面是一個示例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> 
+0

感謝的人.. 。這是我正在尋找...再次感謝:DDD – Jovan

+0

謝謝!這對我有幫助! – pandre