I cannot disable scrolling in the RecyclerView
. I tried calling rv.setEnabled(false)
but I can still scroll.
How can I disable scrolling?
I cannot disable scrolling in the RecyclerView
. I tried calling rv.setEnabled(false)
but I can still scroll.
How can I disable scrolling?
Create class which extend RecyclerView class
This will disable the scroll event, but not the click events
Use this in your XML do the following:
I have been struggling in this issue for some hour, So I would like to share my experience, For the layoutManager solution it is fine but if u want to reEnable scrolling the recycler will back to top.
The best solution so far (for me at least) is using @Zsolt Safrany methode but adding getter and setter so you don't have to remove or add the OnItemTouchListener.
As follow
Usage
You can add this line after setting your adapter
Now your recyclerview will work with smooth scrolling
This works for me:
For API 21 and higher:
No java code needed. You can set
android:nestedScrollingEnabled="false"
in xml:Here is how I did it with data binding:
In place of the "true" I used a boolean variable that changed based on a condition so that the recycler view would switch between being disabled and enabled.