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?
For some reason @Alejandro Gracia answer starts working only after a few second. I found a solution that blocks the RecyclerView instantaneously:
Override onTouchEvent() and onInterceptTouchEvent() and return false if you don't need OnItemTouchListener at all. This does not disable OnClickListeners of ViewHolders.
Wrote a kotlin version:
usage:
in XML :-
You can add
android:nestedScrollingEnabled="false"
in the child RecyclerView layout XML file
or
in Java :-
childRecyclerView.setNestedScrollingEnabled(false);
to your RecyclerView in Java code.
Using ViewCompat (Java) :-
childRecyclerView.setNestedScrollingEnabled(false);
will work only in android_version>21 devices. to work in all devices use the followingViewCompat.setNestedScrollingEnabled(childRecyclerView, false);
Came across with a fragment that contains multiple RecycleView so I only need one scrollbar instead of one scrollbar in each RecycleView.
So I just put the ScrollView in the parent container that contains the 2 RecycleViews and use
android:isScrollContainer="false"
in the RecycleView