问题描述
我有一个AppBarLayout,如果用户向下滚动列表一点,它将展开,如果用户不再滚动,它会在2秒后返回。但是,令人讨厌的是AppBarLayout还在滚动RecyclerView以获得AppBarLayout的高度。这样,它将列表保持在用户在列表中停止的位置,因此列表不会移动,但是视口会移动,如果可能,我想禁用它。
唯一可行的方法是将ViewPager(稍后放在包含RecyclerView的Fragment中)放在AppBarLayout上方并删除app:layout_behavior
。
<androidx.coordinatorlayout.widget.CoordinatorLayout
android:layout_width="0dp"
android:layout_height="0dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/divider_logo">
<androidx.viewpager.widget.ViewPager
android:id="@+id/view_pager"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
<com.google.android.material.appbar.AppBarLayout
android:id="@+id/app_bar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@android:color/white"
app:elevation="0dp"
app:layout_behavior="com.my.app.sava.main.AppBarLayoutBehavior">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_scrollFlags="scroll|enteralways">
<View
android:id="@+id/tv_location_bg"
android:layout_width="0dp"
android:layout_height="0dp"
android:background="@color/colorPrimaryLight"
app:layout_constraintBottom_toBottomOf="@id/tv_location"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="@id/tv_location" />
.
.
.
但是,要滚动时会延迟,因为先滚动AppBarLayout而不移动列表,然后RecyclerView开始滚动。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)