As Marko said, this can be achieved using your own implementation of a OnOffsetChangedListener.
AppBarLayout appBarLayout = (AppBarLayout) view.findViewById(R.id.app_bar_layout);
appBarLayout.addOnOffsetChangedListener(new AppBarLayout.OnOffsetChangedListener() {
@Override
public void onOffsetChanged(AppBarLayout appBarLayout, int verticalOffset) {
if (Math.abs(verticalOffset) == appBarLayout.getTotalScrollRange()) {
// Collapsed
} else if (verticalOffset == 0) {
// Expanded
} else {
// Somewhere in between
}
}
}););
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…