Вы можете добавить a BottomSheetCallback
, чтобы узнать статус и направление.
Что-то вроде:
BottomSheetBehavior<...> bottomSheetBehavior = BottomSheetBehavior.from(bottomSheetLayout);
bottomSheetBehavior.addBottomSheetCallback(new BottomSheetBehavior.BottomSheetCallback() {
@Override public void onStateChanged(@NonNull View bottomSheet, int newState) {
if (newState == BottomSheetBehavior.STATE_DRAGGING){
// Dragging state
}
}
@Override public void onSlide(@NonNull View bottomSheet, float slideOffset) {
// The new offset of this bottom sheet within [-1,1] range.
// Offset increasesas this bottom sheet is moving upward.
// From 0 to 1 the sheet is between collapsed and expanded states and
// From -1 to 0 it is between hidden and collapsed states.
}
});