I know similar question is asked many times but it couldn't solve my issue. So I am asking here. I have a recyclerView with swiperefresh layout. I have used this code
recyclerView1.addOnScrollListener(new RecyclerView.OnScrollListener() {
@Override
public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
//super.onScrollStateChanged(recyclerView, newState);
try {
int firstPos = mLinearLayoutManager.findFirstCompletelyVisibleItemPosition();
if (refreshLayout != null) {
if (firstPos > 0) {
refreshLayout.setEnabled(false);
} else {
activity.refreshLayout.setEnabled(true);
if (recyclerView1.getScrollState() == 1)
if (activity.refreshLayout.isRefreshing())
recyclerView1.stopScroll();
}
}
} catch (Exception e) {
}
}
});
to differentiate the scroll of recyclerView and swipe refresh layout. But I have added a header to this recyclerView using this [Is there an addHeaderView equivalent for RecyclerView?. Now the header height in the recyclerview is too big so in small devices
int firstPos = mLinearLayoutManager.findFirstCompletelyVisibleItemPosition();
is returning 0 when only half of the header is visible. And it is enabling swiperefreshlayout. So I can't see the whole header in recyclerView. Can anybody help me to solve this.
Thanks