[英]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.