RecyclerView
scrolling
Android development
disable scroll
UI components

How to disable RecyclerView scrolling?

Interview Questions practice on Codemia

Over 8,000 real interview questions from top companies, searchable by company and role.

Browse interview questions

Introduction

To disable scrolling in a RecyclerView, the cleanest solution is usually to use a custom LayoutManager that reports it cannot scroll. That is different from disabling nested scrolling, which only changes how the RecyclerView cooperates with a parent scroll container and does not fully turn off its own scroll behavior.

Core Sections

The reliable solution: override scroll capability

If you use LinearLayoutManager, subclass it and override canScrollVertically() or canScrollHorizontally().

java
1import android.content.Context;
2import androidx.recyclerview.widget.LinearLayoutManager;
3
4public class NoScrollLinearLayoutManager extends LinearLayoutManager {
5
6    public NoScrollLinearLayoutManager(Context context) {
7        super(context);
8    }
9
10    @Override
11    public boolean canScrollVertically() {
12        return false;
13    }
14}

Then attach it to the RecyclerView:

java
RecyclerView recyclerView = findViewById(R.id.recyclerView);
recyclerView.setLayoutManager(new NoScrollLinearLayoutManager(this));

This prevents user-driven vertical scrolling while still allowing the adapter and view recycling behavior to work normally.

Horizontal lists use the same idea

For horizontal layouts, override canScrollHorizontally() instead.

java
1public class NoScrollHorizontalLayoutManager extends LinearLayoutManager {
2
3    public NoScrollHorizontalLayoutManager(Context context) {
4        super(context, LinearLayoutManager.HORIZONTAL, false);
5    }
6
7    @Override
8    public boolean canScrollHorizontally() {
9        return false;
10    }
11}

Pick the method that matches the orientation you actually use.

Do not confuse this with nested scrolling

You will often see:

java
recyclerView.setNestedScrollingEnabled(false);

That can be useful when the RecyclerView is inside a NestedScrollView, but it does not truly disable the RecyclerView's own scrolling logic. It mainly changes how scroll events are delegated between parent and child views.

Use it when you want the parent to own scrolling. Do not use it as the only answer if the requirement is "the list itself must not scroll."

Why developers disable scrolling

Common reasons include:

  • placing a short RecyclerView inside a larger scrollable form
  • showing a non-scrollable preview list
  • driving movement through custom gestures or paging logic

When the list is small and fully visible, disabling scroll can simplify the interaction model. When the list is large, it is usually a sign that the layout should be redesigned instead of forcing a non-scrolling RecyclerView into a scrolling parent.

A note about measuring height

If a non-scrolling RecyclerView is nested inside another scroll container, its height must be able to expand enough to show its items. Otherwise you end up with clipped content and no way to reach it. In that scenario, disabling scroll is only half the change; the layout must also measure correctly.

That is one reason nested RecyclerView plus ScrollView combinations often feel awkward. The UI can work, but it deserves extra care.

If the list content changes dynamically, test those states too. A non-scrolling setup that looks correct with three rows can break once the adapter grows to ten rows and the parent layout no longer has enough room.

Common Pitfalls

  • Using setNestedScrollingEnabled(false) and assuming scrolling is fully disabled.
  • Disabling scroll on a long list and creating content the user can no longer reach.
  • Forgetting to override the correct direction method for the layout orientation.
  • Nesting a RecyclerView inside another scroll container without verifying measured height.
  • Solving a layout-design problem with a scrolling hack instead of simplifying the screen structure.

Summary

  • The most reliable way to disable RecyclerView scrolling is with a custom LayoutManager.
  • Override canScrollVertically() or canScrollHorizontally() based on the list orientation.
  • 'setNestedScrollingEnabled(false) changes parent-child coordination, not true scroll capability.'
  • Non-scrolling lists work best when the content is short and fully visible.
  • If the screen still feels forced after disabling scroll, revisit the layout rather than adding more view hacks.

Related reading
Free course
Beginner
7 lessons
2 hours
Tackling System Design Interview Problems

A short course that equips you with the skills to approach system design interviews methodically.

Start the free course
Track what you have practised

A free account saves your progress, solutions and study plan across every problem on Codemia.

Interview Questions practice on Codemia

Over 8,000 real interview questions from top companies, searchable by company and role.

Browse interview questions

All Rights Reserved.