繁体   English   中英

检测RecyclerView的顶部?

[英]Detect the top of RecyclerView?

我有一个RecyclerView,首先它向下滚动,现在当我们向上滚动时,它达到最高点。 我想检测一下。有什么办法吗? 我有AppBar,其高度大于设备宽度。 因此它会导致滚动。 我想通过顶部达到听众手动扩展AppBar以避免投掷。

    if (layoutManager.firstCompletelyVisibleItemPosition() == 0) {
    //this is the top of the RecyclerView 
    }

这个代码我已经使用但我的问题是我在放入此代码后无法向上滚动RecyclerView。 因为我的RecyclerView使用GridLayoutManager有3列。

如果在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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM