Answer the question
In order to leave comments, you need to log in
How to show an arbitrary RecyclerView item?
The following method is needed, with the position parameter (or the item itself) for the RecyclerView (LinearLayoutManager):
1) If the list item is visible on the screen, then do nothing.
2) If the element is below the “visible window” of the list, then scroll the list so that the element is visible at the bottom
3) If the element is above the “visible window” of the list, then scroll the list so that the element is visible at the top
Answer the question
In order to leave comments, you need to log in
To solve your problem, you need to
1) Check the visibility condition + below / above
is solved using the
int findFirstVisibleItemPosition() methods;
int findLastVisibleItemPosition();
or
int findLastCompletelyVisibleItemPosition();
int findFirstCompletelyVisibleItemPosition();
2) Make element top/bottom
is solved using the
scrollToPositionWithOffset(int, int) method
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question