Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RecyclerView Auto Scrolling with GravitySnapHelper #40

Closed
c0d3sling3r opened this issue Dec 8, 2017 · 11 comments
Closed

RecyclerView Auto Scrolling with GravitySnapHelper #40

c0d3sling3r opened this issue Dec 8, 2017 · 11 comments
Labels

Comments

@c0d3sling3r
Copy link

I use RTL horizontal recyclerview with LinearLayoutManager and set GravitySnapHelper(Gravity.END) to it. But after apply a little scroll to left, the recyclerview scrolls to left automatically without any user touches.
I attached a gif following to show the problem:
2017_12_08_14_58_08

@c0d3sling3r
Copy link
Author

c0d3sling3r commented Dec 10, 2017

I found out the problem. Because the recyclerview has a setReverseLayout(true) this happens.

@rubensousa rubensousa added the bug label Dec 10, 2017
@rubensousa
Copy link
Owner

Thanks for the report. I'll try to find a workaround.

@rubensousa
Copy link
Owner

Can you check version 1.5 please? It should be fixed now.

@SetareMaghari
Copy link

hi, i still have this problem, maybe im not using it in the correct way,
i instance the class as:
val SnapHelper = GravitySnapHelper(Gravity.END)
(its kotlin)

then i set layout-manager as:
layoutManager =
GridLayoutManager(context, 1, RecyclerView.HORIZONTAL, true)

is that correct for RTL horizontal scroll?

@rubensousa
Copy link
Owner

@SetareMaghari are you using 1.5? This issue was fixed on 1.5.

If you only have a span count of 1, you should use a LinearLayoutManager instead. But it should work anyway.

@SetareMaghari
Copy link

SetareMaghari commented Dec 30, 2017

@rubensousa yes a use 1.5.
i changed it to linearlayout manager but i still have the problem...
also if i change it to ltr direction there is still the problem!
look at here:

its my code:
recycler.layoutManager =
LinearLayoutManager(context, LinearLayoutManager.HORIZONTAL, false)
val SnapHelper = GravitySnapHelper(Gravity.START)
SnapHelper.attachToRecyclerView(recycler)

and the result:(it jumps to the first!)

ezgif-5-ea45f39327

also the same problem for RTL...

@SetareMaghari
Copy link

@rubensousa can you help me to solve it?

@rubensousa
Copy link
Owner

I can't reproduce this anymore on 1.5. Can you build a sample project and try to reproduce this? If so, please send it to me afterwards.

@rubensousa
Copy link
Owner

Closing due to inactivity

@osama-raddad
Copy link

just use
val snapHelper = GravitySnapHelper(if (recyclerView.layoutDirection != Gravity.END) Gravity.START else Gravity.END)

@mehdijalalifar
Copy link

if use :
getWindow().getDecorView().setLayoutDirection(View.LAYOUT_DIRECTION_RTL);
in your activity , you need
1)add this code in recyclerView in adapter_snap.xml
android:layoutDirection="ltr"

2)snapAdapter.java
set reverseLayout:true
set Gravity:END

ezgif-3-0ddc694c1a

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants