如何在MapView android上添加按钮

时间:2011-08-25 15:47:39

标签: android button android-mapview

从问题中可以看出,我需要在mapView上放置一些按钮,应用程序将通过用户按下按钮,使用当前位置刷新mapView。 我知道怎么把按钮放在上面,但是如何放在地图上? 如果有人有一些示例代码,或者赞赏某些指导帮助......

2 个答案:

答案 0 :(得分:30)

您需要使用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>

答案 1 :(得分:2)

嗨,男人搜索叠加项目是你需要的:D这里谷歌链接 http://developer.android.com/resources/tutorials/views/hello-mapview.html

和好样本:D

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

相关问题