How to disable RecyclerView scrolling?
Interview Questions practice on Codemia
Over 8,000 real interview questions from top companies, searchable by company and role.
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().
Then attach it to the RecyclerView:
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.
Pick the method that matches the orientation you actually use.
Do not confuse this with nested scrolling
You will often see:
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
RecyclerViewinside 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
RecyclerViewinside 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
RecyclerViewscrolling is with a customLayoutManager. - Override
canScrollVertically()orcanScrollHorizontally()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
- how to disable rotation in React Native?
- How to disable scrolling in UITableView table when the content fits on the screen
- How to disable the highlight control state of a UIButton?
- How to disable UITextField editing but still accept touch?
- How to disable/enable the return key in a UITextField?
- How to disable/enable the sleep mode programmatically in iOS?
- How to dismiss an AlertDialog on a FlatButton click?
- How to dismiss keyboard iOS programmatically when pressing return
.png&w=3840&q=75)
Tackling System Design Interview Problems
A short course that equips you with the skills to approach system design interviews methodically.
Start the free courseTrack 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.