浮动操作菜单上的代码正在工作,但其他浮动操作按钮未显示。我在下面有一张Google地图和一个recyclerview。该地图似乎覆盖了其他浮动操作按钮。以下是浮动操作按钮的代码。我关注了一个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地图和recyclerview上。
答案 0 :(得分: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"