There is a method in which the header appears or disappears depending on the scrolling. But since my list changes periodically (number changes), if there are 2-3 items in the list, I don’t want the header to disappear, but alas, it’s impossible to complete it. Who can prompts what efficient? Method:
public void onScrollStateChanged(RecyclerView recyclerView, int newState) { super.onScrollStateChanged(recyclerView, newState); firstVisiblePosition = recyclerLayoutManager.findFirstVisibleItemPosition(); if (lastScrollState == RecyclerView.SCROLL_STATE_DRAGGING && scrollDirection == ScrollDirection.SCROLL_DOWN) { hideHeader(); } else if (lastScrollState == RecyclerView.SCROLL_STATE_DRAGGING && scrollDirection == ScrollDirection.SCROLL_UP && firstVisiblePosition < 10) { showHeader(); } lastScrollState = newState; }