【发布时间】:2021-10-01 12:33:32
【问题描述】:
向上或向下滚动时,我需要帮助将图片中显示的工厂保持在固定位置 这是我的xml
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
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:background="@color/accent"> <android.support.constraint.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/accent"
>
<android.support.v7.widget.RecyclerView
android:id="@+id/listView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:dividerHeight="1dp"
/>
</android.support.constraint.ConstraintLayout>
<android.support.design.widget.FloatingActionButton
android:id="@+id/addmorefab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
android:layout_marginBottom="@dimen/fab_marginBottom"
android:layout_marginRight="@dimen/fab_marginRight"
android:clickable="true"
app:backgroundTint="@color/primary"
app:srcCompat="@drawable/ic_action_new"
app:layout_anchor="@id/listView"
app:layout_anchorGravity="bottom|right|end"
/></android.support.constraint.ConstraintLayout>
我什至尝试制作两个约束布局,但它不起作用
我也尝试过使用 recyclerView.setNestedScrollingEnabled(false); 它有效,但它限制了recyclerview的滚动。 在第二张图片上,我希望工厂在不滚动的地方保持固定
【问题讨论】:
-
为什么不将FAB 留在约束布局?
标签: java android xml android-recyclerview