Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save virendersran01/4afe95f923de1ec7e5cd6188b26bdb10 to your computer and use it in GitHub Desktop.
Save virendersran01/4afe95f923de1ec7e5cd6188b26bdb10 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