当我使用自定义布局而不是通胀时,DialogFragment 不显示任何内容

问题描述

我想用自定义 ui 创建 DialogFragment。使用自己制作的自定义布局对我来说很重要。 但是当从 onCreateView DialogFragment 返回一个时,什么都不显示。顺便说一下,当在简单 Fragment 的子级中使用相同的代码时,视图会按预期显示。

override fun onCreateView(
    inflater: LayoutInflater,container: ViewGroup?,savedInstanceState: Bundle?
): View {
    val context = requireActivity()

    contentLoaderView = createContentLoaderView(context)

    return contentLoaderView
}

private fun createContentLoaderView(context: Context): ContentLoaderView{
    return ContentLoaderView(context).apply{
        attachContentView(R.layout.dialog_product_order)
        attachViewModel(viewLifecycleOwner,viewModel)
        layoutParams = ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,ViewGroup.LayoutParams.MATCH_PARENT)
    }
}

当我使用充气机时,一切都很好。

override fun onCreateView(
    inflater: LayoutInflater,savedInstanceState: Bundle?
): View {
    return LayoutInflater.from(context).inflate(R.layout.dialog_product_order,container,false)
}

我做错了什么?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)