gpt4 book ai didi

android - 如何在 MapView android 上添加按钮

转载 作者:塔克拉玛干 更新时间:2023-11-02 07:53:14 24 4
gpt4 key购买 nike

正如您从问题中看到的那样,我需要在 mapView 上放置一些按钮,应用程序将通过用户按下该按钮,使用当前位置刷新 mapView。我知道如何将按钮放在上面、下面,但是如何放在 map 上???如果有人有一些示例代码,或者一些指导帮助,我们将不胜感激......

最佳答案

您需要使用 RelativeLayout 并将按钮放置在 MapView 的顶部。请确保不要将其放在 Google Logo 上。这是一个示例 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>

关于android - 如何在 MapView android 上添加按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7193358/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com