浮动操作按钮丢失

问题描述 投票:0回答:1

浮动操作菜单上的代码正在运行,但不显示其他浮动操作按钮。我在地图下面有一张谷歌地图和一份回收者视图。似乎地图覆盖了其他浮动动作按钮。下面是浮动操作按钮的代码。我关注了YouTube视频。

<android.support.design.widget.CoordinatorLayout android:id="@+id/profilenav"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MapView"
    background="#FFF9C4"
    android:orientation="vertical"
    android:gravity="center"
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    xmlns:app="http://schemas.android.com/apk/res-auto">

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

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical"
            android:gravity="center">

            <fragment xmlns:android="http://schemas.android.com/apk/res/android"
                xmlns:tools="http://schemas.android.com/tools"
                tools:context=".MapviewPage"
                android:name="com.google.android.gms.maps.SupportMapFragment"
                android:id="@+id/mapview"
                android:layout_width="match_parent"
                android:layout_height="350dp"/>

            <view class="android.support.v7.app.AlertController$RecycleListView"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:scrollbars="vertical"
                android:visibility="visible">
            </view>

        </LinearLayout>

    </ScrollView>

        <android.support.design.widget.FloatingActionButton
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="bottom|end"
            android:layout_marginRight="@dimen/fab_margin_right"
            android:layout_marginBottom="16dp"
            android:src="@drawable/menu"
            android:elevation="6dp"
            android:id="@+id/fab_nav"
            app:pressedTranslationZ="12dp"
            android:backgroundTint="@color/fab1_color"/>

        <android.support.design.widget.FloatingActionButton
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="bottom|end"
            android:layout_marginRight="@dimen/fab_margin_right"
            android:layout_marginBottom="100dp"
            android:src="@drawable/settings"
            android:elevation="6dp"
            android:id="@+id/fab_settings"
            app:pressedTranslationZ="12dp"
            android:backgroundTint="@color/fab2_color"
            android:visibility="invisible"/>

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

这些按钮应覆盖在Google Map和recyclerview上。

android android-layout floating-action-button
1个回答
0
投票

你必须在浮动按钮中再添加两行。

  <android.support.design.widget.CoordinatorLayout android:id="@+id/profilenav"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
     background="#FFF9C4"
    android:orientation="vertical"
    android:gravity="center"
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    xmlns:app="http://schemas.android.com/apk/res-auto">

    <ScrollView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:id="@+id/test"
        app:layout_behavior="@string/appbar_scrolling_view_behavior"
        xmlns:android="http://schemas.android.com/apk/res/android">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical"
            android:gravity="center">


            <fragment xmlns:android="http://schemas.android.com/apk/res/android"
                xmlns:map="http://schemas.android.com/apk/res-auto"
                xmlns:tools="http://schemas.android.com/tools"
                android:id="@+id/map"
                android:name="com.google.android.gms.maps.SupportMapFragment"
                android:layout_width="match_parent"
                android:layout_height="350dp"
                tools:context=".view.activities.TestMap" />
            <view class="android.support.v7.app.AlertController$RecycleListView"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:scrollbars="vertical"
                android:visibility="visible">

            </view>
        </LinearLayout>
    </ScrollView>
    <android.support.design.widget.FloatingActionButton
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="bottom|end"
        android:layout_marginRight="@dimen/fab_margin_right"
        android:layout_marginBottom="16dp"
        android:src="@drawable/ic_check_circle_black_24dp"
        android:elevation="6dp"
        android:id="@+id/fab_nav"
        app:pressedTranslationZ="12dp"
        app:layout_behavior="@string/appbar_scrolling_view_behavior"
        android:backgroundTint="@color/color_type_help"/>
    <android.support.design.widget.FloatingActionButton
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="bottom|end"
        android:layout_marginRight="@dimen/fab_margin_right"
        android:layout_marginBottom="100dp"
        android:src="@drawable/logo"
        android:elevation="6dp"
        android:id="@+id/fab_settings"
        app:pressedTranslationZ="12dp"
        app:layout_anchor="@id/test"
        app:layout_anchorGravity="bottom|right|end"
        app:layout_behavior="@string/appbar_scrolling_view_behavior"
        android:backgroundTint="@color/translucent"
        android:visibility="visible"/>
    </android.support.design.widget.CoordinatorLayout>

三行在浮动按钮中添加此项。

    app:layout_anchor="@id/test"
    app:layout_anchorGravity="bottom|right|end"
    app:layout_behavior="@string/appbar_scrolling_view_behavior"
© www.soinside.com 2019 - 2024. All rights reserved.