[英]How in RecyclerView perform scroll item with some position to top?
I have recyclerview, that have LinearLayoutManager and in it reverseLayout=true
. 我有recyclerview,它具有LinearLayoutManager,并且其中具有
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. 常规的
recyclerView.scrollToPosition
或layoutManager.scrollToPosition
不起作用,因为以这种方式滚动的项目显示在列表的底部和屏幕下方。
用这个 :-
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滚动到颗粒位置
recyclerView.layoutManager.scrollToPosition(0)
In your question you don't reference the recyclerview's layoutmanager
but instead reference both the recylcerview
and layoutmanager
individually. 在你的问题,你不引用recyclerview的
layoutmanager
,而是同时引用了recylcerview
和layoutmanager
逐个。
You much call recylcerview.layoutmanager
你
recylcerview.layoutmanager
打电话给recylcerview.layoutmanager
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.