小编Abh*_*nay的帖子

在默认的Google地图活动上添加按钮

我想在android studio中的默认Googlemap活动之上添加一个按钮。我通过更改Googlemap片段的XML代码来尝试了此操作:

<?xml version="1.0" encoding="utf-8"?>

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >

<fragment
    android:id="@+id/location_map"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    class="com.google.android.gms.maps.SupportMapFragment" />
<Button
    android:id="@+id/button1"
    android:layout_width="match_parent"
    android:layout_height="fill_parent"
    android:padding="0dp"
    android:paddingBottom="0dp"
    android:background="#359c5e"
    android:text="@string/go"
    android:textColor="#ffffff" />
Run Code Online (Sandbox Code Playgroud)

但是我无法在我的地图碎片上得到Button。我通过在XML文件中的Fragment和Viceversa之前编写Button尝试了很多方法,仍然面临着同样的问题。

我的要求是

  1. 在mapfragment上创建一个Button。
  2. 单击它时,它应该显示一些自定义标记。

如何完成这项任务?任何建议表示赞赏。

google-maps mapfragment android-studio

0
推荐指数
1
解决办法
8447
查看次数

标签 统计

android-studio ×1

google-maps ×1

mapfragment ×1