@@ -208,6 +208,7 @@ public abstract static class BottomSheetCallback {
208208
209209 private MaterialShapeDrawable materialShapeDrawable ;
210210
211+ private int gestureInsetBottom ;
211212 private boolean gestureInsetBottomIgnored ;
212213
213214 /** Default Shape Appearance to be used in bottomsheet */
@@ -770,15 +771,19 @@ public final void setPeekHeight(int peekHeight, boolean animate) {
770771 // If sheet is already laid out, recalculate the collapsed offset based on new setting.
771772 // Otherwise, let onLayoutChild handle this later.
772773 if (layout && viewRef != null ) {
773- calculateCollapsedOffset ();
774- if (state == STATE_COLLAPSED ) {
775- V view = viewRef .get ();
776- if (view != null ) {
777- if (animate ) {
778- settleToStatePendingLayout (state );
779- } else {
780- view .requestLayout ();
781- }
774+ updatePeekHeight (animate );
775+ }
776+ }
777+
778+ private void updatePeekHeight (boolean animate ) {
779+ calculateCollapsedOffset ();
780+ if (state == STATE_COLLAPSED ) {
781+ V view = viewRef .get ();
782+ if (view != null ) {
783+ if (animate ) {
784+ settleToStatePendingLayout (state );
785+ } else {
786+ view .requestLayout ();
782787 }
783788 }
784789 }
@@ -1118,7 +1123,7 @@ private int calculatePeekHeight() {
11181123 if (peekHeightAuto ) {
11191124 return Math .max (peekHeightMin , parentHeight - parentWidth * 9 / 16 );
11201125 }
1121- return peekHeight ;
1126+ return peekHeight + ( gestureInsetBottomIgnored ? 0 : gestureInsetBottom ) ;
11221127 }
11231128
11241129 private void calculateCollapsedOffset () {
@@ -1250,7 +1255,8 @@ private void setSystemGestureInsets(@NonNull View child) {
12501255 @ Override
12511256 public WindowInsetsCompat onApplyWindowInsets (
12521257 View view , WindowInsetsCompat insets , RelativePadding initialPadding ) {
1253- setPeekHeight (peekHeight + insets .getMandatorySystemGestureInsets ().bottom );
1258+ gestureInsetBottom = insets .getMandatorySystemGestureInsets ().bottom ;
1259+ updatePeekHeight (/* animate= */ false );
12541260 return insets ;
12551261 }
12561262 });
0 commit comments