【发布时间】:2011-08-25 15:47:38
【问题描述】:
从问题中可以看出,我需要在 mapView 上放置一些按钮,应用程序将通过用户按下按钮来刷新当前位置的 mapView。 我知道怎么把按钮放在上面,下面,但是怎么放在地图上??? 如果有人有一些示例代码,或者一些指导帮助,不胜感激......
【问题讨论】:
标签: android button android-mapview
从问题中可以看出,我需要在 mapView 上放置一些按钮,应用程序将通过用户按下按钮来刷新当前位置的 mapView。 我知道怎么把按钮放在上面,下面,但是怎么放在地图上??? 如果有人有一些示例代码,或者一些指导帮助,不胜感激......
【问题讨论】:
标签: android button android-mapview
您需要使用 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>
【讨论】:
嗨,你需要的是搜索覆盖项目:D 这里是谷歌链接 http://developer.android.com/resources/tutorials/views/hello-mapview.html
和很好的样本:D
【讨论】: