Reputation: 31
How can I position a Recycler View like this.
It initially begins on the right edge of the view showing only just a few elements. And once you begin scrolling, all other elements starts showing.
The default Recycler View would position all elements from the leftmost part of the view.
How can I achieve this?
Upvotes: 3
Views: 2120
Reputation: 2808
Another solution would be to use a ViewPager
for the horizontal scrollable list of items.
With a ViewPager
you can use the following snippet to indent the items:
ViewPager.setPadding(int left, int top, int right, int bottom)
Upvotes: 0
Reputation: 772
I read the other comments and felt like adding this answer. Adding a new type is overkill for achieving your goal. There's a much simpler way (Which I suppose is used in Google Play Music app).
Add horizontal padding to your RecyclerView and prevent clipping.
Here is what it would look like in xml:
<android.support.v7.widget.RecyclerView
android:id="@+id/rv"
android:layout_width="match_parent"
android:layout_height="250dp"
android:clipToPadding="false"
android:paddingLeft="10dp"
android:paddingRight="10dp" />
The key here is android:clipToPadding="false"
Upvotes: 2