【发布时间】:2021-03-17 10:17:21
【问题描述】:
我想每次都显示FloatingActionButton 右下角(同时滚动)。但是当我将它与RecyclerView 一起使用时,它不会显示在RecyclerView 上。它显示在RecyclerView 下方。
这是我的布局:
<?xml version="1.0" encoding="utf-8"?>
<androidx.coordinatorlayout.widget.CoordinatorLayout
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">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/kitapListeRw"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="@+id/kitapEkleBtn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|right"
android:clickable="true"
android:layout_marginBottom="10dp"
android:layout_marginRight="10dp"
app:srcCompat="@drawable/ic_add_24dp" />
</androidx.coordinatorlayout.widget.CoordinatorLayout>
如何每次都显示FAB右下角而不是RecyclerView下方?
【问题讨论】:
-
不确定我是否正确理解了您的问题,但请尝试将您的
RecyclerView包装在ScrollView中。 -
我想固定 FAB。即使滚动recyclerview。
标签: android android-recyclerview floating-action-button coordinator-layout