我在 viewpager 中有片段,因此片段由 Recyclerview 和 FloatingActionButton 组成。因此,当我滚动 recyclerview 时,工具栏折叠和 tablayout 引脚,但浮动操作按钮也会向上滚动。我想将 FlootingActionButton 固定到它的位置。
请让我知道如何将 FloatingActionButton 固定在右下角。
这是 XML 文件 -
<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:id="@+id/coordinatorLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
android:fitsSystemWindows="true">
<android.support.v7.widget.RecyclerView
android:id="@+id/recycler_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/md_grey_200" />
<android.support.design.widget.FloatingActionButton
android:id="@+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="16dp"
android:src="@drawable/ic_calendar_icon"
app:backgroundTint="@color/primary"
app:elevation="2dp"
app:fabSize="normal"
app:layout_anchor="@+id/recycler_view"
app:layout_anchorGravity="bottom|right|end"
app:layout_dodgeInsetEdges="right|bottom|top|left"
app:layout_insetEdge="bottom"
app:pressedTranslationZ="12dp" />
</android.support.design.widget.CoordinatorLayout>