我处于一种情况,CollapsingToolbarLayout
到目前为止RecyclerView
,一切都很好,现在我有一个必须使用的PagerSnapHelper
要求RecyclerView
val snapHelper: SnapHelper = PagerSnapHelper()
snapHelper.attachToRecyclerView(activityNewsBinding.newsRecyclerView)
仅当我RecyclerView
折叠. 我没有发现任何与和相关的问题RecyclerView
CollapsingToolbarLayout
PagerSnapHelper
CollapsingToolbarLayout
这是我的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>