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
Update: This bug has been fixed in the version 23.1.1 of support library
You can set onOffsetChanged listener for your AppBarLayout and prevent to swipe refreshing until AppBarLayout layout offset 0.
This is good example : https://gist.github.com/blackcj/001a90c7775765ad5212
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);
}