[英]Detect the top of RecyclerView?
I have a RecyclerView, first its scrolled down, now when we scroll up, it reach top most point. 我有一个RecyclerView,首先它向下滚动,现在当我们向上滚动时,它达到最高点。 I want to detect that .Is there any way?
我想检测一下。有什么办法吗? I have AppBar whose height is greater than device width.
我有AppBar,其高度大于设备宽度。 so it cause an fling on scroll.
因此它会导致滚动。 I thought by getting top reached listener manually expand AppBar to avoid fling.
我想通过顶部达到听众手动扩展AppBar以避免投掷。
if (layoutManager.firstCompletelyVisibleItemPosition() == 0) {
//this is the top of the RecyclerView
}
this code i already used but my issue is that i can't scroll up RecyclerView after putting this code. 这个代码我已经使用但我的问题是我在放入此代码后无法向上滚动RecyclerView。 Because my RecyclerView uses GridLayoutManager with 3 columns.
因为我的RecyclerView使用GridLayoutManager有3列。
If you have a LinearLayoutManager
set on your RecyclerView
you can use it to find the first visible item: 如果在
RecyclerView
上设置了LinearLayoutManager
,则可以使用它来查找第一个可见项:
LinearLayoutManager layoutManager = new LinearLayoutManager(this);
recyclerview.setLayoutManager(layoutManager);
if (layoutManager.firstCompletelyVisibleItemPosition() == 0) {
//this is the top of the RecyclerView
//Do Something
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.