Solution 1 :
void BottomSheetBehavior.setGestureInsetBottomIgnored(boolean gestureInsetBottomIgnored)
Sets whether this bottom sheet should adjust it’s position based on the system gesture area on Android Q and above.
Problem :
I have a fragment with a bottom sheet inside coordinator layout. I am setting the peak height of the sheet as 60 dp. It looks fine on a phone without a notch.
But in a phone with a notch, it is also including the height of the bottom navigation view of the phone. So lets say if the height of bottom navigation is also 60 dp then the bottom sheet is showing a peak height of 120 dp instead of 60 dp. Testing on Samsung M31.
Layout file –
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns_android="http://schemas.android.com/apk/res/android"
xmlns_app="http://schemas.android.com/apk/res-auto">
<data>
</data>
<androidx.coordinatorlayout.widget.CoordinatorLayout
android_layout_width="match_parent"
android_layout_height="match_parent">
<FrameLayout
android_id="@+id/scanner_container"
android_layout_width="match_parent"
android_layout_height="match_parent" />
<androidx.constraintlayout.widget.ConstraintLayout
android_id="@+id/header_layout"
android_layout_width="match_parent"
android_layout_height="wrap_content"
android_minHeight="@dimen/dp_150"
android_background="@color/dashboard_bg"
android_paddingStart="@dimen/dp_25"
android_paddingBottom="@dimen/dp_40"
android_paddingEnd="@dimen/dp_25">
<ImageView
android_id="@+id/logo_imageview"
android_layout_width="@dimen/dp_50"
android_layout_height="@dimen/dp_50"
android_background="@drawable/circle_white"
app_layout_constraintBottom_toBottomOf="parent"
app_layout_constraintStart_toStartOf="parent"
app_layout_constraintTop_toTopOf="parent" />
<LinearLayout
android_id="@+id/company_details_linear_layout"
android_layout_width="0dp"
android_layout_height="wrap_content"
android_layout_marginStart="@dimen/dp_15"
android_layout_marginEnd="@dimen/dp_25"
android_orientation="vertical"
app_layout_constraintBottom_toBottomOf="@id/logo_imageview"
app_layout_constraintEnd_toStartOf="@+id/imageView3"
app_layout_constraintStart_toEndOf="@+id/logo_imageview"
app_layout_constraintTop_toTopOf="@id/logo_imageview">
<TextView
android_layout_width="wrap_content"
android_layout_height="wrap_content"
android_fontFamily="@font/open_sans"
android_text="@string/welcome"
android_textSize="@dimen/sp_14" />
<TextView
android_layout_width="wrap_content"
android_layout_height="wrap_content"
android_layout_marginTop="@dimen/dp_4"
android_fontFamily="@font/open_sans_bold"
android_text="@string/company_name"
android_textSize="@dimen/sp_14" />
</LinearLayout>
<ImageView
android_id="@+id/help_imageview"
android_layout_width="wrap_content"
android_layout_height="wrap_content"
android_src="@drawable/ic_help"
app_layout_constraintEnd_toEndOf="parent"
app_layout_constraintTop_toTopOf="@id/company_details_linear_layout" />
<ImageView
android_id="@+id/imageView3"
android_layout_width="wrap_content"
android_layout_height="wrap_content"
android_layout_marginEnd="@dimen/dp_25"
android_adjustViewBounds="true"
android_src="@drawable/ic_notification"
app_layout_constraintEnd_toEndOf="parent"
app_layout_constraintEnd_toStartOf="@+id/help_imageview"
app_layout_constraintTop_toTopOf="@id/company_details_linear_layout" />
<TextView
android_layout_width="wrap_content"
android_layout_height="wrap_content"
android_layout_marginTop="@dimen/dp_6"
android_drawableEnd="@drawable/ic_arrow_right"
android_drawablePadding="@dimen/dp_8"
android_drawableTint="@color/error_red"
android_fontFamily="@font/open_sans_semibold"
android_letterSpacing="0.01"
android_text="@string/verify_your_account"
android_textAllCaps="true"
android_textColor="@color/error_red"
android_textSize="@dimen/sp_10"
app_layout_constraintBottom_toBottomOf="parent"
app_layout_constraintStart_toStartOf="@id/company_details_linear_layout"
app_layout_constraintTop_toBottomOf="@id/company_details_linear_layout"
app_layout_constraintVertical_bias="0.0" />
</androidx.constraintlayout.widget.ConstraintLayout>
<include
android_id="@+id/bottom_sheet"
layout="@layout/dashboard_bottom_sheet"
android_layout_width="match_parent"
android_layout_height="match_parent"
app_behavior_hideable="false"
app_behavior_peekHeight="@dimen/dp_60"
app_layout_behavior="com.google.android.material.bottomsheet.BottomSheetBehavior" />
</androidx.coordinatorlayout.widget.CoordinatorLayout>
</layout>