BottomSheetDialog visible in bottom even in hidden state on Android 10



Explaining the image:-

  1. Login button = To show login view
  2. Sign up button = To show sign up view
  3. Forgot Password bottom sheet

(Image is edited to hide logos)

Problem = BottomSheetFragment is visible in bottom
Devices tested = Samsung, RealMe = both with android 10

XML of welcome page

<?xml version="1.0" encoding="utf-8"?>
<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android=""

    <include layout="@layout/activity_welcome_content" />

    <include layout="@layout/fragment_sign_in" />

    <include layout="@layout/fragment_sign_up" />

    <include layout="@layout/fragment_forgot_password" />


xml code using in all fragments


Also implemented this theme to have a custom design of sheet and have a invisible background of default sheet

<style name="AppBottomSheetTheme" parent="Theme.Design.Light.BottomSheetDialog">
    <item name="bottomSheetStyle">@style/AppModalStyle</item>

<style name="AppModalStyle" parent="Widget.Design.BottomSheet.Modal">
    <item name="android:background">@color/trans</item>
    <item name="behavior_hideable">true</item>
    <item name="behavior_peekHeight">500dp</item>

Also tried this in welcome class

//using kotlin
forgotSheetBehavior.isHideable = true
forgotSheetBehavior.state = BottomSheetBehavior.STATE_HIDDEN

Still seeing the BottomSheetDialogFragment in the bottom, this is not visible in the emulator of pixel with android 10


Due to some reason

I needed to use BottomSheetBehaviour on every BottomSheetDialogFragment to hide them on start

//using kotlin
forgotSheetBehavior.isHideable = true
forgotSheetBehavior.state = BottomSheetBehavior.STATE_HIDDEN

After using BottomSheetBehaviour on every SheetFragment and calling it onCreate() solved the problem

Answered By – Rahul Gaur

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published