Material-components-android: [Bottom Sheet] Bottom Sheet peek height gives different results on API 29

Created on 9 Jul 2020  ·  2Comments  ·  Source: material-components/material-components-android

Description: The bottom sheet's peek height appears differently on API 29. It works correctly for 28 and below but gives incorrect peek behavior on 29.

Expected behavior: I set the peak height to be 77dp which should only show the bottom navigation bar at start. On API 27,28 it shows up correctly, as you can see on the left emulator device on which we can only see the bottom bar. But on API 29 as you can see on the right, it shows some extra space from beneath which is incorrect. It only occurs on API 29.
image

Source code: I have attached a minimal project that shows this behavior. Please run this on API 29 and 28,27 to see the difference.
BottomSheetPeekError.zip

Android API version: 29

Material Library version: 1.3.0-alpha01, 1.2.0-beta01, 1.2.0-alpha06 (they all give incorrect peak height on API 29, the minimum I have to use is 1.2.0-alpha05)

Device: Multiple devices running API 29

bug

Most helpful comment

maybe caused by gesture bottom insets ,BottomSheet will set gesture bottom insets in default behavior that available on API 29 to avoid BottomSheet Gesture conflicts with System Navigation Gesture,you can try use setGestureInsetBottomIgnored(true) to solve this issue , sample code:

BottomSheetBehavior<View> behavior = BottomSheetBehavior.from(bottomSheetBehaviorView);
behavior.setGestureInsetBottomIgnored(true);

or In Style:

in styles.xml

<style name="Widget.MyBottomSheetBehavior" >
    <item name="gestureInsetBottomIgnored">true</item>
</style>

<style name="AppTheme">
    <item name="bottomSheetStyle">@style/Widget.MyBottomSheetBehavior>
</style>

in your layout file
<View
    android:id="@+id/my_bottom_sheet_view"
    style="?attr/bottomSheetStyle"
</View>

All 2 comments

maybe caused by gesture bottom insets ,BottomSheet will set gesture bottom insets in default behavior that available on API 29 to avoid BottomSheet Gesture conflicts with System Navigation Gesture,you can try use setGestureInsetBottomIgnored(true) to solve this issue , sample code:

BottomSheetBehavior<View> behavior = BottomSheetBehavior.from(bottomSheetBehaviorView);
behavior.setGestureInsetBottomIgnored(true);

or In Style:

in styles.xml

<style name="Widget.MyBottomSheetBehavior" >
    <item name="gestureInsetBottomIgnored">true</item>
</style>

<style name="AppTheme">
    <item name="bottomSheetStyle">@style/Widget.MyBottomSheetBehavior>
</style>

in your layout file
<View
    android:id="@+id/my_bottom_sheet_view"
    style="?attr/bottomSheetStyle"
</View>

Changed In style. It worked for me. Thanks @dsn5ft

maybe caused by gesture bottom insets ,BottomSheet will set gesture bottom insets in default behavior that available on API 29 to avoid BottomSheet Gesture conflicts with System Navigation Gesture,you can try use setGestureInsetBottomIgnored(true) to solve this issue , sample code:

BottomSheetBehavior<View> behavior = BottomSheetBehavior.from(bottomSheetBehaviorView);
behavior.setGestureInsetBottomIgnored(true);

or In Style:

in styles.xml

<style name="Widget.MyBottomSheetBehavior" >
    <item name="gestureInsetBottomIgnored">true</item>
</style>

<style name="AppTheme">
    <item name="bottomSheetStyle">@style/Widget.MyBottomSheetBehavior>
</style>

in your layout file
<View
    android:id="@+id/my_bottom_sheet_view"
    style="?attr/bottomSheetStyle"
</View>
Was this page helpful?
0 / 5 - 0 ratings