Horizontal ListView in Android?
Interview Questions practice on Codemia
Over 8,000 real interview questions from top companies, searchable by company and role.
Introduction
If you want a horizontal scrolling list in Android, the modern answer is usually not ListView at all. The standard solution is RecyclerView with a horizontal LinearLayoutManager, because it handles recycling, scrolling, and item decoration far better than the older ListView workarounds.
Use RecyclerView with a Horizontal Layout Manager
Start by placing a RecyclerView in your layout.
Then configure it in code with a horizontal LinearLayoutManager.
That single layout-manager setting is what turns the list sideways.
A Minimal Adapter Looks Familiar
The adapter pattern is the same as any other RecyclerView.
What changes is not the adapter itself but the scroll direction and the item layout assumptions.
Why Not HorizontalScrollView Plus Manual Children
For a handful of static views, a HorizontalScrollView may be acceptable. But once the content is data-driven or can grow, RecyclerView is the better long-term choice because it recycles views, supports snapping, and integrates with the rest of the modern Android UI stack.
Older custom "HorizontalListView" widgets mostly existed to work around limitations that RecyclerView already solved.
Improve the UX with Snapping and Spacing
Horizontal lists often benefit from SnapHelper so scrolling lands cleanly on card boundaries.
Item spacing is usually cleaner when handled by ItemDecoration rather than by hard-coding margins into every layout.
These small details matter because horizontal lists are often used for carousels, image strips, and recommendation shelves where polish is very visible.
Watch Nested Scrolling Behavior
A horizontal list often lives inside a vertically scrolling screen. That is fine, but gesture interaction should be tested carefully. Poorly sized items or overly greedy parents can make sideways scrolling feel broken even when the code is technically correct.
This is a UX problem as much as a widget problem.
Accessibility also deserves explicit attention in horizontal collections. Focus order, content descriptions, and predictable sideways navigation matter more in carousels than many teams expect, because the layout is less conventional than a simple vertical list.
Testing on small and large screens matters too, because horizontal card widths that feel fine on one device can become cramped or wasteful on another. Item sizing should be treated as part of the component design, not as an afterthought.
Common Pitfalls
Reaching for old custom horizontal ListView libraries instead of using RecyclerView adds complexity for no real benefit in modern Android code.
Designing item layouts as if the list were vertical often produces awkward widths and poor touch targets.
Ignoring nested-scroll behavior can make the horizontal list feel unreliable inside a vertical parent layout.
Summary
- For a horizontal list in Android, use
RecyclerView, not legacyListViewworkarounds. - Set a horizontal
LinearLayoutManagerto change scroll direction. - Use the same adapter pattern you would use for any
RecyclerView. - Add snapping and spacing deliberately for a better carousel-like experience.
Related reading
- HorizontalScrollView within ScrollView Touch Handling
- How big should a UIBarButtonItem image be?
- How can a divider line be added in an Android RecyclerView?
- How can a web application send push notifications to iOS devices?
- How can get data from address-book faster in Android?
- How can I access getSupportFragmentManager in a fragment?
- How can I access my localhost from my Android device?
- How can I access my localhost from my Android device?
.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.