有没有办法在DialogFragment的顶部显示片段?当我的BottomSheetDialogFragment在某些操作后显示时,我需要显示另一个片段(不是对话框片段),而不必关闭该对话框,我尝试从对话框中删除模糊效果,然后隐藏视图,但那不好,对话框片段是不可见的,但它仍然在顶部,按下返回键会先删除这个不可见的对话框,我需要实现的是正常的后台堆栈顺序,就像“普通”片段一样
我也遇到了同样的问题,我找到的解决方案是:
In the BottomSheetDialogFragment layout, set an id to a ViewGroup (you can use the root view or add a FrameLayout somewhere)
In the BottomSheetDialogFragment class use this to open the new fragment:
childFragmentManager.beginTransaction()
.add(R.id.yourId, newFragment, newFragment.tag)
.addToBackStack(newFragment.tag)
.commit()
parentFragmentManager.popBackStack()
。