Showing balloon with bottomsheetfragment visible #807
Replies: 1 comment
-
|
This is a window z-order problem. Using Solution 1 — Show the balloon only after the BottomSheet is dismissed (safest)If you're listening to a Flow, buffer the balloon request and hold it until no overlay is blocking: // In your ViewModel or wherever you control the flow
private val pendingBalloon = MutableStateFlow<BalloonEvent?>(null)
// When BottomSheet closes, consume and show the balloon
fun onBottomSheetDismissed() {
pendingBalloon.value?.let { event ->
showBalloon(event)
pendingBalloon.value = null
}
}Register a Solution 2 — Anchor the balloon to a View inside the BottomSheetIf you can pass a reference to any View inside the BottomSheet as the anchor, the balloon's // In your BottomSheetFragment
val anchorView = view.findViewById<View>(R.id.some_view)
eventBus.post(ShowBalloonEvent(anchorView)) // pass to your flow listenerSolution 3 — Use WindowManager overlay (API 26+, requires permission)For a truly always-on-top balloon you'd need Recommended approachSolution 1 (delay until BottomSheet dismisses) is the most user-friendly — a balloon appearing while a modal is open is unexpected UX anyway. Solution 2 is right if the balloon is contextually tied to something inside the sheet. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I have a problem, I am listening to a flow events to show balloons on screen throughout app. Problem arises when there is a bottomsheet fragment being shown on screen when the balloon is shown it is greyed out in the background. I am using findViewById(android.R.id.content) for my anchor view, and I do not have an instance of the bottomsheet to get its rootview.
I would like for balloon to be shown above all possible shown dialogs/bottomsheets on screen.
Beta Was this translation helpful? Give feedback.
All reactions