【问题标题】:How can I add button on MapView android如何在 MapView android 上添加按钮
【发布时间】:2011-08-25 15:47:38
【问题描述】:

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

【问题讨论】:

    标签: android button android-mapview


    【解决方案1】:

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

    【讨论】:

    • 谢谢伙计...这就是我正在寻找的...再次感谢:DDD
    • 谢谢!这对我很有帮助!
    【解决方案2】:

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

    和很好的样本:D

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

    【讨论】:

    • 我没有时间查看该代码,但我会...谢谢您的麻烦 ;)))
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-11-11
    • 2013-06-29
    相关资源
    最近更新 更多