rubensousa / GravitySnapHelper

A SnapHelper that snaps a RecyclerView to an edge.
Apache License 2.0
5k stars 614 forks source link

can not scroll to the top position when call smoothScrollToPosition(0) #68

Open Hoalq-0026 opened 3 years ago

Hoalq-0026 commented 3 years ago

@rubensousa Hi! I have a problem. I can not scroll to the top position when the call method smoothScrollToPosition(0) in source code:

ryclerviewTopic.apply {
                layoutManager = LinearLayoutManager(context)
               enableSnapping(false)
                adapter = topicAdapter
            }

ryclerviewTopic.smoothScrollToPosition(0)

 <com.github.rubensousa.gravitysnaphelper.GravitySnapRecyclerView
                        android:id="@+id/ryclerviewTopic"
                        android:layout_width="match_parent"
                        android:layout_height="match_parent"
                        app:layout_constraintEnd_toEndOf="parent"
                        app:layout_constraintStart_toStartOf="parent"
                        app:layout_constraintTop_toTopOf="parent"
                        app:layout_behavior="@string/appbar_scrolling_view_behavior"
                        app:snapEnabled="false"
                        app:snapGravity="top"
                        app:snapMaxFlingSizeFraction="2"
                        app:snapScrollMsPerInch="50"
                        android:paddingTop="@dimen/_30dp"
                        tools:listitem="@layout/item_home_topic" />

Originally posted by @Hoalq-0026 in https://github.com/rubensousa/GravitySnapHelper/issues/64#issuecomment-722192004