【问题标题】:BottomSheetDialogFragment is not open, small white bar only showBottomSheetDialogFragment 没有打开,小白条只显示
【发布时间】:2020-11-23 03:05:49
【问题描述】:

我创建了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")

【问题讨论】:

    标签: android kotlin android-fragments android-dialogfragment


    【解决方案1】:

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

    【讨论】:

      【解决方案2】:

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

      【讨论】:

        【解决方案3】:

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

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2014-11-09
          • 1970-01-01
          相关资源
          最近更新 更多