0

I am in a situation where i have CollapsingToolbarLayout and RecyclerView and so far every thing works pretty fine now i have a requirement where i have to use PagerSnapHelper with RecyclerView

val snapHelper: SnapHelper = PagerSnapHelper()
snapHelper.attachToRecyclerView(activityNewsBinding.newsRecyclerView)

Once i attach to RecyclerView my scroll on the RecyclerView is not smooth anymore only when i am collapsing the CollapsingToolbarLayout. I didn't find any issue related to PagerSnapHelper and CollapsingToolbarLayout

Here is my 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>
Osama Aftab
  • 1,161
  • 9
  • 15

1 Answers1

0

I was able to solve this issue by making changes in PagerSnapHelper class.

Osama Aftab
  • 1,161
  • 9
  • 15
  • ` by making changes in PagerSnapHelper` you would have to add the detail of _what_ you changed in your answer as well, for others to see in future :) – a_local_nobody Jan 16 '21 at 11:01