John Ackerman
John Ackerman

Reputation: 23

How to make recyclerview width larger than the layout width?

I want to make the width of a recyclerView wider than the width of the layout itself so that only a part of the items of the recyclerView could be seen until the user scroll to the left.

I think an image can explain it better:

Each item of the recyclerView have 5 textViews like this:

SS1

And I want to see only 4 of them until the user scrolls to the left like this:

SS2

After scrolling, the first textView shouldn't be seen until the user scrolls to the right.

How can I accomplish that? Should I change the item layout to be larger than the screen or the recyclerView?

Upvotes: 2

Views: 747

Answers (1)

Monster Brain
Monster Brain

Reputation: 2119

You must be looking for something like this.

Recyclerview inside horizontal scroll view

  1. Embed the RecyclerView (nestedScrollingEnabled=false) inside a Horizontal Scrollview
  2. List item for Recyclerview should have the width set to wrap_content

You can checkout this project on Github

Upvotes: 2

Related Questions