微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

如何在MapView android上添加按钮

从这个问题可以看出,我需要在mapView上放置一些按钮,应用程序将通过用户按下按钮来更新当前位置的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>

原文地址:https://www.jb51.cc/android/311881.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐