Skip to content

Instantly share code, notes, and snippets.

@MrCrambo
Created July 7, 2020 15:39
Show Gist options
  • Save MrCrambo/ba6943bd18f1008032985282bcdf4eb9 to your computer and use it in GitHub Desktop.
Save MrCrambo/ba6943bd18f1008032985282bcdf4eb9 to your computer and use it in GitHub Desktop.
LinearLayout bottomSheet = findViewById(R.id.bottom_sheet_behavior_id);
BottomSheetBehavior bottomSheetBehavior = BottomSheetBehavior.from(bottomSheet);
// ..
// here you could find all the UI views inside your bottom sheet and initialize them
// ..
// ..
// setting the bottom sheet callback for interacting with state changes and sliding
bottomSheetBehavior.setBottomSheetCallback(new BottomSheetBehavior.BottomSheetCallback() {
@Override
public void onStateChanged(View view, int i) {
// do something when state changes
}
@Override
public void onSlide(View view, float v) {
// do something when slide happens
}
});
// ..
// set the bottom sheet callback state to hidden when you just start your app
bottomSheetBehavior.setState(BottomSheetBehavior.STATE_HIDDEN);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment