How to disable RecyclerView scrolling?

recyclerview disable scrolling programmatically
show all items in recyclerview without scrolling
android-recyclerview disable scroll xml
disable effect scroll in recyclerview
recyclerview in scrollview
recyclerview scroll not working
nestedscrollview recyclerview scroll to top
how to disable recyclerview in android

I cannot disable scrolling in the RecyclerView. I tried calling rv.setEnabled(false) but I can still scroll.

How can I disable 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:
 public class CustomGridLayoutManager extends LinearLayoutManager {
 private boolean isScrollEnabled = true;

 public CustomGridLayoutManager(Context context) {
  super(context);
 }

 public void setScrollEnabled(boolean flag) {
  this.isScrollEnabled = flag;
 }

 @Override
 public boolean canScrollVertically() {
  //Similarly you can customize "canScrollHorizontally()" for managing horizontal scroll
  return isScrollEnabled && super.canScrollVertically();
 }
}

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.

 linearLayoutManager = new LinearLayoutManager(context) {
 @Override
 public boolean canScrollVertically() {
  return false;
 }
};

How to disable RecyclerView scrolling?, I cannot disable scrolling in the RecyclerView . I tried calling rv.setEnabled(false) but I can still scroll. How can I disable scrolling? Answers:. In this android programming source code example, we are going to explore how to disable RecyclerView scrolling in android. Have you thought of disabling android RecyclerView scrolling? The sample code below will give you some insight on how this can be achieved.

The real answer is

recyclerView.setNestedScrollingEnabled(false);

More info in documentation

stop recyclerview scroll · GitHub, Have you thought of disabling android RecyclerView scrolling? The sample code below will give you some insight on how this can be achieved. activity_main.xml In this android kotlin source code example, we are going to disable RecyclerView scrolling in Kotlin. You can copy and adopt this source code example to your Kotlin android project without reinventing the wheel. Below is a step by step source code to disable RecyclerView scrolling in Kotlin.

The REAL REAL answer is: For API 21 and higher:

No java code needed. You can set android:nestedScrollingEnabled="false" in xml:

<android.support.v7.widget.RecyclerView
     android:id="@+id/recycler"
     android:layout_width="match_parent"
     android:layout_height="wrap_content"
     android:clipToPadding="true"
     android:nestedScrollingEnabled="false"
     tools:listitem="@layout/adapter_favorite_place">

How to Disable RecyclerView Scrolling in Android, Updated: 14 Dec, 2019. “Android Notes 6: How to Remove RecyclerView's Scroll Effect [UPDATED]” is published by Kuray Ogun in FreakyCoder Software Blog. Updated: 14 Dec, 2019. This code segment provides you to control your RecyclerView’s scroll effect. You can open or close it. Gist:

This a bit hackish workaround but it works; you can enable/disable scrolling in the RecyclerView.

This is an empty RecyclerView.OnItemTouchListener stealing every touch event thus disabling the target RecyclerView.

public class RecyclerViewDisabler implements RecyclerView.OnItemTouchListener {

    @Override
    public boolean onInterceptTouchEvent(RecyclerView rv, MotionEvent e) {
        return true;
    }

    @Override
    public void onTouchEvent(RecyclerView rv, MotionEvent e) {

    }

    @Override
    public void onRequestDisallowInterceptTouchEvent(boolean disallowIntercept) {

    }
}

Using it:

RecyclerView rv = ...
RecyclerView.OnItemTouchListener disabler = new RecyclerViewDisabler();

rv.addOnItemTouchListener(disabler);        // disables scolling
// do stuff while scrolling is disabled
rv.removeOnItemTouchListener(disabler);     // scrolling is enabled again 

Android Notes 6: How to Remove RecyclerView's Scroll Effect , I finally found a solution. Create Custom LinearLayoutManager public class CustomLinearLayoutManager extends LinearLayoutManager { public  This will disable the scroll event, but not the click events. Use this class for the "child" RecyclerView. You want the PARENT recyclerview to scroll, but not the child. Well this should do that, since the parent will just be the standard RecyclerView, but the child will be this custom one with no scrolling, but handles clicks.

This works for me:

  recyclerView.setOnTouchListener(new View.OnTouchListener() {
      @Override
      public boolean onTouch(View v, MotionEvent event) {
          return true;
      }
  });

Disable Scrolling in child Recyclerview android, I cannot disable scrolling in the RecyclerView. I tried calling rv.setEnabled(false) but I can still scroll. How can I disable scrolling? ScrollView 2. In android ScrollView there is no way or method to disable scrolling. but sometime if you want to disable scrolling of ScrollView while you are inside inner element, like if you want to disable ScrollView when you are inside Map view. So you can scroll Map view easily if you put Map view inside ScrollView.

Disable RecyclerView Scrolling – Pupli, recyclerView.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { return true; }  Only Ian's answer was able to make my RecyclerView scroll to a specified position. However, The RecyclerView was not able to scroll afterwards when I used scrollToPosition(). smoothScrollToPosition() worked but the initial animation made it too slow when the list was long. The reason was the listener was not removed.

RecyclerView within NestedScrollView Scrolling Issue, I've written some other Android-related content, and if you liked what you read here, you'll probably also enjoy this: Disable Shift Label Animation from Bottom  Scrolling RecyclerView – Part 1 February 20, 2015 February 8, 2015 Mark Allison 8 Comments In this series of articles we’ll take a look in to scrolling behaviour of RecyclerView , and discover some oddities that may crop up, and some options for fixing them.

How can I disable RecyclerView's ability to scroll if all items fit on the , How can I disable RecyclerView's ability to scroll if all items fit on the screen, or if there I have a toolbar that collapses when the recycler view is scrolled up. 2 Answers 2. Logically, it is not a good idea to put ListView inside a ScrollView. However, if you insist then: You may either increase the ListView height based on the sum of its rows height as mentioned here. Or let the recycling in place but intercept the touch on ListView to redirect scrolling to its parent ScrollView as mentioned here.

Comments
  • What is the point of using RecyclerView if you do not want scrolling?
  • @CommonsWare, I just want to disable it temporarily, for instance, while I'm doing a custom animation with one of its children.
  • Ah, OK, that makes sense. I'd've probably put a transparent View over top of the RecyclerView, toggling between VISIBLE and GONE as needed, but off the cuff your approach seems reasonable.
  • Hope this helps find a better solution.
  • @CommonsWare, here's what I need it for, for example. I need to display images in RecyclerView one at a time, without partially visible images, only one in my viewport. And there are arrows on the left and on the right which user can navigate with. Depending on what image is currently displayed (they are of various types), some things outside RecyclerView are triggered. It's the design our customers want.
  • This should be the correct answer as it disables scrolling while allowing me to click.
  • Disabling scrolling on the default LayoutMangers should already exist, a user of the API should not have to do this. Thanks for the answer though!
  • What if I want to disable scrolling only from a certain item ? Meaning you can scroll down (or up) to it, but then get blocked, till I re-enable it again?
  • This also disables smoothScrollToPosition
  • you add kotlin version object :LinearLayoutManager(this){ override fun canScrollVertically(): Boolean { return false } }