diff --git a/lib/java/com/google/android/material/bottomsheet/BottomSheetBehavior.java b/lib/java/com/google/android/material/bottomsheet/BottomSheetBehavior.java index e152fd18f6a..f4097dd6c9b 100644 --- a/lib/java/com/google/android/material/bottomsheet/BottomSheetBehavior.java +++ b/lib/java/com/google/android/material/bottomsheet/BottomSheetBehavior.java @@ -292,6 +292,8 @@ void onLayout(@NonNull View bottomSheet) {} private boolean nestedScrolled; + private float hideFriction = HIDE_FRICTION; + private int childHeight; int parentWidth; int parentHeight; @@ -1144,6 +1146,28 @@ public int getSaveFlags() { return this.saveFlags; } + /** + * Sets the friction coefficient to hide the bottom sheet, or set it to the next closest + * expanded state. + * + * @param hideFriction The friction coefficient that determines the swipe velocity needed to + * hide or set the bottom sheet to the closest expanded state. + */ + public void setHideFriction(float hideFriction) { + this.hideFriction = hideFriction; + } + + /** + * Gets the friction coefficient to hide the bottom sheet, or set it to the next closest + * expanded state. + * + * @return The friction coefficient that determines the swipe velocity needed to hide or set the + * bottom sheet to the closest expanded state. + */ + public float getHideFriction() { + return this.hideFriction; + } + /** * Sets a callback to be notified of bottom sheet events. * @@ -1393,7 +1417,7 @@ boolean shouldHide(@NonNull View child, float yvel) { return false; } int peek = calculatePeekHeight(); - final float newTop = child.getTop() + yvel * HIDE_FRICTION; + final float newTop = child.getTop() + yvel * hideFriction; return Math.abs(newTop - collapsedOffset) / (float) peek > HIDE_THRESHOLD; }