The AppBarLayout
has a Switch to be notified of changes of offset
.
I believe it is possible to be notified when it is completely collapsed or expanded as follows:
AppBarLayout.OnOffsetChangedListener listener = new AppBarLayout.OnOffsetChangedListener() {
@Override
public void onOffsetChanged(AppBarLayout appBarLayout, int verticalOffset) {
if(collapsingToolbar.getHeight() + verticalOffset < 2 * ViewCompat.getMinimumHeight(collapsingToolbar)) {
// CollapsingToolbar esta colapsado
} else {
// CollapsingToolbar esta expandindo
}
}
};
appBar.addOnOffsetChangedListener(listener);
Source: https://stackoverflow.com/questions/31595741/show-view-when-toolbar-collapses