File tree 1 file changed +25
-1
lines changed
lib/java/com/google/android/material/bottomsheet
1 file changed +25
-1
lines changed Original file line number Diff line number Diff line change @@ -292,6 +292,8 @@ void onLayout(@NonNull View bottomSheet) {}
292
292
293
293
private boolean nestedScrolled ;
294
294
295
+ private float hideFriction = HIDE_FRICTION ;
296
+
295
297
private int childHeight ;
296
298
int parentWidth ;
297
299
int parentHeight ;
@@ -1144,6 +1146,28 @@ public int getSaveFlags() {
1144
1146
return this .saveFlags ;
1145
1147
}
1146
1148
1149
+ /**
1150
+ * Sets the friction coefficient to hide the bottom sheet, or set it to the next closest
1151
+ * expanded state.
1152
+ *
1153
+ * @param hideFriction The friction coefficient that determines the swipe velocity needed to
1154
+ * hide or set the bottom sheet to the closest expanded state.
1155
+ */
1156
+ public void setHideFriction (float hideFriction ) {
1157
+ this .hideFriction = hideFriction ;
1158
+ }
1159
+
1160
+ /**
1161
+ * Gets the friction coefficient to hide the bottom sheet, or set it to the next closest
1162
+ * expanded state.
1163
+ *
1164
+ * @return The friction coefficient that determines the swipe velocity needed to hide or set the
1165
+ * bottom sheet to the closest expanded state.
1166
+ */
1167
+ public float getHideFriction () {
1168
+ return this .hideFriction ;
1169
+ }
1170
+
1147
1171
/**
1148
1172
* Sets a callback to be notified of bottom sheet events.
1149
1173
*
@@ -1393,7 +1417,7 @@ boolean shouldHide(@NonNull View child, float yvel) {
1393
1417
return false ;
1394
1418
}
1395
1419
int peek = calculatePeekHeight ();
1396
- final float newTop = child .getTop () + yvel * HIDE_FRICTION ;
1420
+ final float newTop = child .getTop () + yvel * hideFriction ;
1397
1421
return Math .abs (newTop - collapsedOffset ) / (float ) peek > HIDE_THRESHOLD ;
1398
1422
}
1399
1423
You can’t perform that action at this time.
0 commit comments