My android project includes a recyclerView that contains a list of cardViews, and also there is a swipeRefreshLayout on the top of this recyclerView. When I scroll down the list
Maybe I am late, but have a try to this solution:
mRecyclerView = (RecyclerView) view.findViewById(R.id.recyclerView);
mLayoutManager = new LinearLayoutManager(getActivity()); // a LinearLayoutManager
mRecyclerView.setLayoutManager(mLayoutManager); // setting layoutManager on our RecyclerView
// Adding ScrollListener to getting whether we're on First Item position or not
mRecyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() {
@Override
public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
super.onScrolled(recyclerView, dx, dy);
mSwipeRefreshLayout.setEnabled(mLinearLayoutManager.findFirstCompletelyVisibleItemPosition() == 0); // 0 is for first item position
}
});
mSwipeRefreshLayout
is your SwipeRefreshLayout
After putting above code, you'll be able to swipe only when your First item is visible.
Hope this helps!