2011-08-25 99 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