我有一个RecyclerView,首先它向下滚动,现在当我们向上滚动时,它达到最高点。我想检测一下。有什么办法吗?我有AppBar,其高度大于设备宽度。因此它会导致滚动。我想通过顶部达到听众手动扩展AppBar以避免投掷。
if (layoutManager.firstCompletelyVisibleItemPosition() == 0) {
//this is the top of the RecyclerView
}
这个代码我已经使用但我的问题是我在放入此代码后无法向上滚动RecyclerView。因为我的RecyclerView使用GridLayoutManager有3列。
如果您在LinearLayoutManager
上设置了RecyclerView
,则可以使用它来查找第一个可见项目:
LinearLayoutManager layoutManager = new LinearLayoutManager(this);
recyclerview.setLayoutManager(layoutManager);
if (layoutManager.firstCompletelyVisibleItemPosition() == 0) {
//this is the top of the RecyclerView
//Do Something
}