Java “地图视图”中的按钮不可见

Java “地图视图”中的按钮不可见,java,android,Java,Android,我在MapView中的按钮可见性有问题 布局: <com.google.android.gms.maps.MapView android:id="@+id/map" android:layout_width="match_parent" android:layout_height="match_parent"> <Button android:layout_width="wrap_content" android

我在MapView中的按钮可见性有问题

布局:

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

    <Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="UPDATE DATA"
        android:layout_gravity="center_horizontal"
        android:id="@+id/updateMarkers"/>

</com.google.android.gms.maps.MapView>
但当我在初始化mapView之前初始化按钮时,一切似乎都正常,但按钮并没有显示。 您知道如何在我的情况下正确显示按钮吗?

您是否尝试过以下方法:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    app:layout_behavior="@string/appbar_scrolling_view_behavior"
    tools:context="com.ad3luc.maps.AMain"
    tools:showIn="@layout/activity_main">

    <com.google.android.gms.maps.MapView
        android:id="@+id/map_view"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"/>

    <Button
        android:id="@+id/btn"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_alignParentEnd="true"
        android:layout_alignParentLeft="true"
        android:layout_alignParentRight="true"
        android:layout_alignParentStart="true"
        android:text="Button"/>
</RelativeLayout>

使用RelativeLayout并在布局中放置地图视图按钮小部件。
我没有使用地图的api密钥,但是MapView小部件上的按钮显示没有问题。

非常感谢!这正是我想要的:)
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    app:layout_behavior="@string/appbar_scrolling_view_behavior"
    tools:context="com.ad3luc.maps.AMain"
    tools:showIn="@layout/activity_main">

    <com.google.android.gms.maps.MapView
        android:id="@+id/map_view"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"/>

    <Button
        android:id="@+id/btn"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_alignParentEnd="true"
        android:layout_alignParentLeft="true"
        android:layout_alignParentRight="true"
        android:layout_alignParentStart="true"
        android:text="Button"/>
</RelativeLayout>