2
我的佈局中有兩個FloatingActionButton。兩者都以相同的方式附加到CoordinatorLayout。如何讓SnackBar推起幾個FloatingActionButton?
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout
android:id="@+id/drawerLayout"
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:fitsSystemWindows="true">
<android.support.design.widget.CoordinatorLayout
android:id="@+id/coordinatorLayout"
android:layout_width="match_parent"
android:layout_height="match_parent">
[ appbar, toolbar, content... ]
<android.support.design.widget.FloatingActionButton
android:id="@+id/anon_fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="88dp"
android:layout_marginRight="@dimen/fab_margin"
android:clickable="true"
android:onClick="onFabClick"
android:src="@drawable/ic_cloud_upload_white_24dp"
android:tint="?colorAccent"
app:backgroundTint="@color/tint_inverted_fab"
app:borderWidth="0dp"
app:layout_anchor="@id/coordinatorLayout"
app:layout_anchorGravity="bottom|end"
/>
<android.support.design.widget.FloatingActionButton
android:id="@+id/keyboard_fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="@dimen/fab_margin"
android:clickable="true"
android:onClick="onFabClick"
android:src="@drawable/ic_keyboard_white_24dp"
app:borderWidth="0dp"
app:layout_anchor="@id/coordinatorLayout"
app:layout_anchorGravity="bottom|end"
/>
</android.support.design.widget.CoordinatorLayout>
<android.support.design.widget.NavigationView
android:id="@+id/navigation_view"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
android:fitsSystemWindows="true"
app:headerLayout="@layout/navigation_header"
app:menu="@menu/drawer"/>
</android.support.v4.widget.DrawerLayout>
但是,當我顯示小吃店時,只有底部的FAB上下移動。
Snackbar.make(mCoordinator, "FAB pressed", Snackbar.LENGTH_LONG).show();
如何使兩個移動?