I\'m trying to implement collapsing tollbar with swipe to refresh and recyclerview. When I\'m trying to scroll (when recyclerview has only one item) toolbar collapse, but when
I managed it by adding the following implementation of OnOffsetChangedListener in fragment:
@Override
public void onOffsetChanged(AppBarLayout appBarLayout, int verticalOffset) {
if (collapsingToolbarLayout.getHeight() + verticalOffset < 2 * ViewCompat.getMinimumHeight(collapsingToolbarLayout)) {
swipeRefreshLayout.setEnabled(false);
} else {
swipeRefreshLayout.setEnabled(true);
}
}
@Override
public void onResume() {
super.onResume();
appBarLayout.addOnOffsetChangedListener(this);
}
@Override
public void onPause() {
super.onPause();
appBarLayout.removeOnOffsetChangedListener(this);
}