Skip to content

Commit 53d49e3

Browse files
committed
[BottomSheet] Changed bottom gesture inset handling to ensure a minimum peek height with a buffer built in, instead of always adding the inset to the peek height (when gesture nav is enabled)
PiperOrigin-RevId: 325866040 (cherry picked from commit 0df7724)
1 parent 42b03b3 commit 53d49e3

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

lib/java/com/google/android/material/bottomsheet/BottomSheetBehavior.java

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,9 @@ public abstract static class BottomSheetCallback {
203203
/** Minimum peek height permitted. */
204204
private int peekHeightMin;
205205

206+
/** Peek height gesture inset buffer to ensure enough swipeable space. */
207+
private int peekHeightGestureInsetBuffer;
208+
206209
/** True if Behavior has a non-null value for the @shapeAppearance attribute */
207210
private boolean shapeThemingEnabled;
208211

@@ -273,6 +276,10 @@ public BottomSheetBehavior() {}
273276

274277
public BottomSheetBehavior(@NonNull Context context, @Nullable AttributeSet attrs) {
275278
super(context, attrs);
279+
280+
peekHeightGestureInsetBuffer =
281+
context.getResources().getDimensionPixelSize(R.dimen.mtrl_min_touch_target_size);
282+
276283
TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.BottomSheetBehavior_Layout);
277284
this.shapeThemingEnabled = a.hasValue(R.styleable.BottomSheetBehavior_Layout_shapeAppearance);
278285
boolean hasBackgroundTint = a.hasValue(R.styleable.BottomSheetBehavior_Layout_backgroundTint);
@@ -1125,7 +1132,10 @@ private int calculatePeekHeight() {
11251132
if (peekHeightAuto) {
11261133
return Math.max(peekHeightMin, parentHeight - parentWidth * 9 / 16);
11271134
}
1128-
return peekHeight + (gestureInsetBottomIgnored ? 0 : gestureInsetBottom);
1135+
if (!gestureInsetBottomIgnored && gestureInsetBottom > 0) {
1136+
return Math.max(peekHeight, gestureInsetBottom + peekHeightGestureInsetBuffer);
1137+
}
1138+
return peekHeight;
11291139
}
11301140

11311141
private void calculateCollapsedOffset() {

0 commit comments

Comments
 (0)