Is there any way to display fragment on top of DialogFragment
? When my BottomSheetDialogFragment
is shown after some action I need to display another fragment (not type of dialog fragment) without dismiss of the that dialog, I tried to remove dim effect from dialog and than hide the view, but that is not good, dialog fragment is invisible but, it is steel on top and back press removes this invisible dialog first, what I need to achieve is normal back stack order, like "normal" fragments
How to display another fragment on top of BottomSheetDialogFragment
Asked Answered
I was having the same problem and the solution I found is:
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()
Caveat: when you press the back button it closes the entire dialog, so I put an X icon in the second fragment that calls parentFragmentManager.popBackStack()
© 2022 - 2024 — McMap. All rights reserved.