I'm looking for a component that could work for a ...
# compose
d
I'm looking for a component that could work for a 'popup' effect on my screen. Something where it could appear to be 'on top of' other screen components (raised z axis) but having some trouble implementing. At first I thought a Box would be good, but when that is embedded in a row and column it will resize and move other components around. I want it to appear above these components instead - is there a way to do that with a box or should I be using a different component?
for additional context - this would be something like a help box that give users context about something on the screen
l
Can you use Dialog or AlertDialog?
j
I was just looking at this for my project and I took a look at the implementation of the DropDownMenu composable and found the Popup composable which it uses internally: https://developer.android.com/reference/kotlin/androidx/compose/ui/window/package-summary#Popup(androidx.compose.ui.A[…]Properties,kotlin.Function0)
I haven’t used it so can’t give you much guidance, but it seems like it could be good for what you’re looking to do
Or AlertDialog as Landry said, especially if you want the popup to be modal
l
Good point. I would look at Popup if you don’t need it to go away if you tap outside, and Dialog if you do. Keep in mind that AlertDialog provides an easy way to have a message and a few buttons, but Dialog is much more flexible. If AlertDialog matches what you need, it’s a great choice.
o
We have recently build something similar for modal bottom sheet lib, check
FullscreenPopup
component. It is basically build the same as
Popup
, but lays out always fullscreen. https://github.com/oleksandrbalan/modalsheet/blob/main/modalsheet/src/main/java/eu/wewox/modalsheet/FullscreenPopup.kt