Suppose I have these elements in the activity:
this is a nice workaround, but It's still very different than what the Play Store shows:
for each fragment, call something like that:
recyclerView.addOnScrollListener(new OnScrollListener() {
@Override
public void onScrollStateChanged(final RecyclerView recyclerView, final int newState) {
super.onScrollStateChanged(recyclerView, newState);
((MainActivity) getActivity()).onScrollStateChanged(recyclerView, newState);
}
@Override
public void onScrolled(final RecyclerView recyclerView, final int dx, final int dy) {
super.onScrolled(recyclerView, dx, dy);
((MainActivity) getActivity()).onScrolled(recyclerView, dx,dy);
}
});
for the hosting activity:
public void onScrollStateChanged(final RecyclerView recyclerView, final int newState) {
switch (newState) {
case RecyclerView.SCROLL_STATE_IDLE:
mAppBarLayout.setExpanded(mLastDy <= 0, true);
mLastDy = 0;
break;
}
}
public void onScrolled(final RecyclerView recyclerView, final int dx, final int dy) {
mLastDy = dy == 0 ? mLastDy : dy;
}
Still, if anyone knows how to make it work well (using either ListView or RecyclerView for the fragments), just like on the Play-Store and other apps, please write it down.