Java 如何在RecyclerView中为项目制作粘性按钮?
我有一个带有可扩展项的Java 如何在RecyclerView中为项目制作粘性按钮?,java,android,android-recyclerview,Java,Android,Android Recyclerview,我有一个带有可扩展项的RecyclerView,每个项都有自己的列表。我希望在滚动时项目上有一个特定的按钮是粘性的,如下图中的Apply for selected shift按钮 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:la
RecyclerView
,每个项都有自己的列表。我希望在滚动时项目上有一个特定的按钮是粘性的,如下图中的Apply for selected shift
按钮
<RelativeLayout
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"
android:padding="16dp"
tools:context=".fragments.TestFragment">
<LinearLayout
android:id="@+id/test"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="@id/Id_btn"
android:layout_alignParentTop="true"
android:orientation="vertical">
<android.support.v7.widget.RecyclerView
android:id="@+id/Id_recyc"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
>
</android.support.v7.widget.RecyclerView>
</LinearLayout>
<android.support.v7.widget.AppCompatButton
android:id="@+id/Id_btn"
android:layout_width="match_parent"
android:layout_height="@dimen/btn_height"
android:layout_marginTop="10dp"
android:text="test"
android:layout_alignParentBottom="true"
android:textAllCaps="false"/>
</RelativeLayout>
这会将按钮放置在屏幕底部,而与recyclerview的长度无关。按钮会根据您的需要固定在其位置,希望它有所帮助什么是“Sitchy按钮”,以及它在您显示的图像上的位置?所有这些按钮在我看来都是规则的。粘性按钮是一个在滚动时保持在固定位置的按钮。应用按钮应该是粘性的“到目前为止你尝试了什么”?使用项目装饰器,但感觉不一样,因为它所做的只是画画,而不是一个可点击的视图:/n你是说一个浮动操作按钮吗?每个项目都应该有自己的按钮,假设您扩展了两个项,它们都应该有apply按钮您可以轻松地在adapter类中添加按钮只需在适配器的xml中添加按钮,并且您可以在onBindViewHolder中执行所需操作,以便每个项都有自己的按钮