How to add button in Maps?

Asked

Viewed 934 times

4

I selected a Google Maps Activity when creating the project, as I added this button in 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">

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>

Browser other questions tagged

You are not signed in. Login or sign up in order to post.