Android 折叠工具栏布局和回收视图的滚动问题
我现在的处境是,我有Android 折叠工具栏布局和回收视图的滚动问题,android,android-recyclerview,android-collapsingtoolbarlayout,pagersnaphelper,Android,Android Recyclerview,Android Collapsingtoolbarlayout,Pagersnaphelper,我现在的处境是,我有折叠工具栏布局和回收视图,到目前为止,一切都很好,现在我有一个要求,我必须使用PagerSnapHelper和回收视图 val snapHelper: SnapHelper = PagerSnapHelper() snapHelper.attachToRecyclerView(activityNewsBinding.newsRecyclerView) 一旦我连接到RecyclerView上,我在RecyclerView上的滚动不再平滑,只有在我折叠折叠工具栏布局时。 我没有
折叠工具栏布局
和回收视图
,到目前为止,一切都很好,现在我有一个要求,我必须使用PagerSnapHelper
和回收视图
val snapHelper: SnapHelper = PagerSnapHelper()
snapHelper.attachToRecyclerView(activityNewsBinding.newsRecyclerView)
一旦我连接到RecyclerView
上,我在RecyclerView
上的滚动不再平滑,只有在我折叠折叠工具栏布局时。
我没有发现与PagerSnapHelper
和折叠工具栏布局
这是我的xml
<androidx.coordinatorlayout.widget.CoordinatorLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.google.android.material.appbar.AppBarLayout
android:id="@+id/appbarLayout"
android:layout_width="match_parent"
android:layout_height="500dp">
<com.google.android.material.appbar.CollapsingToolbarLayout
android:id="@+id/collapsing_toolbar_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:contentScrim="?attr/colorPrimary"
app:layout_scrollFlags="scroll|exitUntilCollapsed">
<ImageView
android:id="@+id/expandedImage"
android:layout_width="match_parent"
android:layout_height="500dp"
android:scaleType="centerCrop"
android:src="@drawable/ic_launcher_background" />
</com.google.android.material.appbar.CollapsingToolbarLayout>
</com.google.android.material.appbar.AppBarLayout>
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/newsRecyclerView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="-30dp"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
tools:context=".news.presentation.ui.MyNewsActivity" />
</androidx.coordinatorlayout.widget.CoordinatorLayout>
将此行添加到您的recyclerView xml文件中:
android:nestedScrollingEnabled="false"
或在java代码中:
RecyclerView.setNestedScrollingEnabled(false);
我可以通过在PagerSnapHelper
类中进行更改来解决此问题。不,它在折叠后不会再次展开工具栏。`通过在PagerSnapHelper中进行更改`您还必须在您的答案中添加更改内容的详细信息,以便其他人将来看到:)