Currently I am using the follow code to check whether SwipeRefreshLayout should be enabled.
private void laySwipeToggle() {     if (mRecyclerView.getChildCount() == 0 || mRecyclerView.getChildAt(0).getTop() == 0) {         mLaySwipe.setEnabled(true);     } else {         mLaySwipe.setEnabled(false);     } } But here is the problem. When it's scrolled to another item's view's boundary mRecyclerView.getChildAt(0).getTop() also returns 0.

Is there something like RecyclerView.isScrolledToBottom() or RecyclerView.isScrolledToTop()?
EDIT: (mRecyclerView.getChildAt(0).getTop() == 0 && linearLayoutManager.findFirstVisibleItemPosition() == 0) kind of does the RecyclerView.isScrolledToTop(), but what about RecyclerView.isScrolledToBottom()?
You can use Scroll listener to detect scroll up or down changes in RecyclerView . RecycleView invokes the onScrollStateChanged() method before onScrolled() method. The onScrollStateChanged() method provides you the RecycleView's status: SCROLL_STATE_IDLE : No scrolling.
Recyclerview scroll to bottom using scrollToPositon. After setting the adapter, then call the scrollToPosition function to scroll the recycler view to the bottom.
mLinearLayoutManager = new LinearLayoutManager(this); recyclerView. setLayoutManager(mLinearLayoutManager); 3). On your Button onClick , do this to scroll to the bottom of your RecyclerView .
The solution is in the layout manager.
LinearLayoutManager layoutManager = new LinearLayoutManager(this);  // Add this to your Recycler view recyclerView.setLayoutManager(layoutManager);  // To check if at the top of recycler view if(layoutManager.firstCompletelyVisibleItemPosition()==0){     // Its at top }  // To check if at the bottom of recycler view if(layoutManager.lastCompletelyVisibleItemPosition()==data.size()-1){     // Its at bottom } EDIT
In case your item size is larger than the screen use the following to detect the top event.
RecyclerView recyclerView = (RecyclerView) view; LinearLayoutManager linearLayoutManager = (LinearLayoutManager) recyclerView.getLayoutManager();  int pos = linearLayoutManager.findFirstVisibleItemPosition();  if(linearLayoutManager.findViewByPosition(pos).getTop()==0 && pos==0){     return true; } PS: Actually, if you place the RecyclerView directly inside the SwipeRefreshview you wouldn't need to do this 
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With