Closed leeprohacker closed 4 years ago
The top position won't be called in onSnap
if it can't be snapped. This usually happens when you don't have padding or decoration for the top or bottom items.
@rubensousa rube I looked into your example, in the row Center with decoration, it's same issue i mentioned above. In fact my project I have added decoration to make item center horizontal. So do you have any advices for me? Thanks
@leeprohacker I can confirm there's a problem. Sometimes the position 0 isn't dispatched on onSnap
. I'll fix this in the next release
@leeprohacker it should be fixed in the develop branch now. Can you check if now it behaves like you would expect?
You can check this in your app by installing the version 2.2.1-beta01
Released on 2.2.1
@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" />
The issue when I set GravitySnapRecyclerView equal center and also set SnapListener for GravitySnapHelper. So the listener never callback "onSnap" when the recyclerview scrolled to top position and rest positions that working fine.