BottomSheetDialogFragment没有打开,小白条只显示

BottomSheetDialogFragment is not open, small white bar only show

我已经创建了 BottomSheetDialogFragment 并访问了我的片段,但它没有完全打开,它只显示底部的小条,如下所示

我使用的是默认 BottomSheetDialogFragment 文件,没有进行任何更改。

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" />

显示通话功能

val addBottomDialogFragment: SettingFragment = SettingFragment.newInstance(10)

addBottomDialogFragment.show(supportFragmentManager, "tag")

因为您的 BottomSheet 没有内容,您必须向其中添加内容

BottomSheet 的高度取决于子内容的高度所以首先你应该在底部 sheet 视图下添加一些子视图或内容。如果您使用 RecyclerView,则使用数据设置适配器。

您的底部 sheet 根元素应为“线性布局”或“相对布局”,并将背景设置为透明。