Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Circular RecyclerView

Let's say we the following set of item Views:

View1 -> View2 -> View3 -> ... -> View(n-1) -> View(n)

On classic RecyclerView, View1 would be on first position and View(n) on last. Now I would like to make that circular so after last position we scroll again to first position:

View1 -> View2 -> View3 -> ... -> View(n-1) -> View(n) -> View1 -> View2 -> ...

This at first look seems simple to make but I am not sure how to accomplish that "reset" after View(n). Any advice would be really helpful. Thank you.

like image 645
user4386126 Avatar asked Feb 13 '15 04:02

user4386126


Video Answer


1 Answers

Please refer to this solution for ListView. You may write a RecyclerView.Adapter that has Integer.MAX_VALUE items. The only difference is that RecyclerView no longer has setSelectionFromTop method. Instead you should call

recyclerView.getLayoutManager().scrollToPosition(recyclerAdapter.MIDDLE);

in order to scroll the recyclerView to the middle at first.

like image 114
misaka-10032 Avatar answered Sep 30 '22 06:09

misaka-10032