Home > Back-end >  Unable to draw a layout on top of a bottom sheet
Unable to draw a layout on top of a bottom sheet

Time:04-16

I have created a custom progress bar and I have added it to the window decorview's root view. However, when a bottom sheet is visible, this progress bar is drawn behind the bottom sheet rather than drawing on top of it. Shouldn't it be drawn on top of the bottom sheet?

val loader = FullScreenLoader(
requireContext(),
containerView = requireActivity().window.decorView.rootView as ViewGroup
)

loader.show()

enter image description here

CodePudding user response:

Shouldn't it be drawn on top of the bottom sheet?

It behaves as expected as the progress bar is attached to the activity's window, not to the bottom sheet window.

Bottom sheets behave like dialogs (actually there are versions of them that extend Dialogs like BottomSheetDialog & BottomSheetDialogFragment. Like dialogs, if we tap outside the Bottom Sheet, it is dismissed just. there are also slide up and slide down to activate and deactivate the Bottom Sheet respectively.

If you want that progress bar overlay on top of the BottomSheet, you need to attach it to the BottomSheet dialog window instead of the activity's window.

  • Related