I have recyclerview, that have LinearLayoutManager and in it reverseLayout=true
. How can I scroll item with some position to the top of the screen? Regular recyclerView.scrollToPosition
or layoutManager.scrollToPosition
didn't work, because item scrolled by that way displayed at the bottom of list and under the screen.
用这个 :-
linearLayoutManager!!.scrollToPositionWithOffset(0, 0)
try this
recyclerView.scrollToPosition(recyclerView.getChildCount());
or
recyclerView.scrollToPosition(list.size());
Edit
in your adapter you can check your current position, if you reach desired position you can scroll recyclerView to particulate position using interface
recyclerView.layoutManager.scrollToPosition(0)
In your question you don't reference the recyclerview's layoutmanager
but instead reference both the recylcerview
and layoutmanager
individually.
You much call recylcerview.layoutmanager
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.