Search code examples
androidkotlinandroid-fragmentsandroid-dialogfragment

BottomSheetDialogFragment is not open, small white bar only show


I have created BottomSheetDialogFragment and access into my fragment but it not open fully, it shows only small bar in bottom like below

enter image description here

I am using default BottomSheetDialogFragment file without changing anything.

xml

<?xml version="1.0" encoding="utf-8"?>
<androidx.recyclerview.widget.RecyclerView 
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/list"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:clipToPadding="false"
    android:paddingTop="@dimen/list_item_spacing_half"
    android:paddingBottom="@dimen/list_item_spacing_half"
    tools:context=".ui.SettingFragment"
    tools:listitem="@layout/fragment_setting_list_dialog_item" />

Show call function

val addBottomDialogFragment: SettingFragment = SettingFragment.newInstance(10)

addBottomDialogFragment.show(supportFragmentManager, "tag")

Solution

  • Height of BottomSheet depend on child content height So first you should add some child view or content under bottom sheet view. If you using RecyclerView then set adapter with data.