Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save franciscofranco/fe32f2d244005dae66c576e85b7903fa to your computer and use it in GitHub Desktop.
Save franciscofranco/fe32f2d244005dae66c576e85b7903fa to your computer and use it in GitHub Desktop.
bottomSheetBehavior.addBottomSheetCallback(new BottomSheetBehavior.BottomSheetCallback() {
@Override
public void onStateChanged(@NonNull View bottomSheet, int newState) {
if (newState == BottomSheetBehavior.STATE_EXPANDED) {
// do stuff when the drawer is expanded
}
if (newState == BottomSheetBehavior.STATE_COLLAPSED) {
// do stuff when the drawer is collapsed
}
}
@Override
public void onSlide(@NonNull View bottomSheet, float slideOffset) {
// do stuff during the actual drag event for example
// animating a background color change based on the offset
// or for example hidding or showing a fab
if (slideOffset > 0.2) {
if (fab.isShown()) {
fab.hide();
}
} else if (slideOffset < 0.15) {
if (!fab.isShown()) {
fab.show();
}
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment