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?
Add
in your child of SrollView or NestedScrollView (and parent of ListView, recyclerview and gridview any one)
Just add this to your recycleview in xml
like this
There is a realy simple answer.
The above code disables RecyclerView vertically scrolling.
You should override the layoutmanager of your recycleview for this. This way it will only disable scrolling, none of ther other functionalities. You will still be able to handle click or any other touch events. For example:-
Original:
Here using "isScrollEnabled" flag you can enable/disable scrolling functionality of your recycle-view temporarily.
Also:
Simple override your existing implementation to disable scrolling and allow clicking.
If you just disable only scroll functionality of
RecyclerView
then you can usesetLayoutFrozen(true);
method ofRecyclerView
. But it can not be disable touch event.Extend the
LayoutManager
and overridecanScrollHorizontally()
andcanScrollVertically()
to disable scrolling.Be aware that inserting items at the beginning will not automatically scroll back to the beginning, to get around this do something like: