How to add button in Maps?

4

I selected a Google Maps activity at the time the project was created, how do I add this button to the layout?

<Button
        android:id="@+id/btn_draw_State"
        android:layout_width="40dp"
        android:layout_height="40dp"
        android:layout_gravity="right|top"
        android:layout_marginTop="55dp"
        android:layout_marginRight="11dp" />

Layout:

<fragment
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
android:layout_height="match_parent" android:id="@+id/map" tools:context=".MapsActivityWifi"
android:name="com.google.android.gms.maps.SupportMapFragment">
    
asked by anonymous 15.03.2015 / 20:36

1 answer

2

An XML layout can only have one root, so you should tailor your layout, a suggestion would be:

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

    <fragment 
        android:id="@+id/map"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:name="com.google.android.gms.maps.SupportMapFragment"/>

    <Button
        android:id="@+id/btn_draw_State"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:padding="16dp"
        android:layout_gravity="right|top"
        android:layout_marginTop="55dp"
        android:layout_marginRight="11dp" />

</FrameLayout>
    
15.03.2015 / 22:44