【问题标题】:Floating action button not visible over the Google Map in Android Studio浮动操作按钮在 Android Studio 中的 Google 地图上不可见
【发布时间】:2019-01-07 05:17:04
【问题描述】:

我的屏幕顶部有一个自动完成 Google 搜索,下方有一个 Google 地图,底部有一个浮动操作按钮。

当我尝试在底部的谷歌地图上添加一个浮动操作按钮时,该按钮在屏幕上不可见。

这是我的 activity_maps.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    tools:context=".MapsActivity"
    android:orientation="vertical"
    android:weightSum="1">


    <fragment
            android:id="@+id/place_autocomplete"
            android:name="com.google.android.gms.location.places.ui.PlaceAutocompleteFragment"

            android:layout_width="match_parent"
            android:layout_height="55dp" 
        />



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

        />

   <android.support.design.widget.CoordinatorLayout
    android:layout_width="wrap_content"
    android:layout_height="35dp">
    <android.support.design.widget.FloatingActionButton
        android:id="@+id/fab"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="bottom|end"
        android:layout_marginRight="8dp"
        android:layout_marginBottom="112dp"
        android:src="@android:drawable/ic_menu_search"/>


</android.support.design.widget.CoordinatorLayout>



</LinearLayout>

【问题讨论】:

  • 你有多少个xml文件?
  • 只有这一个文件。
  • 所以你的java文件膨胀了这个?

标签: android google-maps android-studio autocomplete floating-action-button


【解决方案1】:

试试这个

<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout 
    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">

<android.support.design.widget.AppBarLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:theme="@style/AppTheme.AppBarOverlay">

    <fragment
        android:id="@+id/place_autocomplete"
        android:name="com.google.android.gms.location.places.ui.PlaceAutocompleteFragment"
        android:layout_width="match_parent"
        android:layout_height="55dp" />
</android.support.design.widget.AppBarLayout>


<fragment
    android:id="@+id/map"
    class="com.google.android.gms.maps.SupportMapFragment"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    app:layout_behavior="@string/appbar_scrolling_view_behavior"

    />

<android.support.design.widget.FloatingActionButton
    android:id="@+id/fab"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="bottom|end"
    android:layout_marginBottom="8dp"
    android:layout_marginRight="8dp"
    android:src="@android:drawable/ic_menu_search" />
</android.support.design.widget.CoordinatorLayout>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2020-01-02
    • 2021-10-24
    • 2020-02-26
    • 1970-01-01
    • 1970-01-01
    • 2020-07-17
    • 2015-12-02
    • 2017-02-03
    相关资源
    最近更新 更多