Is there a way to draw outside of a composables bo...
# compose
a
Is there a way to draw outside of a composables bounds? Or to render a nested composable on top of (higher z-Index) as a composable that has a different parent? e.g.
Copy code
Box {
  Box { 
    Composable1() <-- render this "on top of" (higher zIndex) Composable2
  }
  Composable2()
}
o
We have faced the similar problem recently as we need to show the bottom sheet above (z-index) the bottom navigation. And we came up with an idea of the “FullscreenPopup”: https://github.com/oleksandrbalan/modalsheet/blob/main/modalsheet/src/main/java/eu/wewox/modalsheet/FullscreenPopup.kt Which allows to add a composable to it’s own window, thus it will be shown on top of everything (even system UI).
s
Also just got to mention, have you considered changing the ordering of those two items? When I’m inside a BoxScope I consider the order I call the composables the order in which they’ll draw on top of each other. In all such cases changing the order to what I was going for was the fix.
a
@Stylianos Gakis the case I posted is very much simplified. The actual use case is that we want to host dialogs locally, e.g. next to the calling site in compose, which works, but the parent composable has the compose equivalent of
fitsSystemWindows
which means drawing the darkened background behind the dialogs will not cover the whole screen. we have moved the darkened background further up the compose hierarchy where it can cover the whole screen, but would like the dialog itself to be close to the calling site (for lambdas etc) but still draw above the darkening background
s
I’d then consider giving the FullscreenPopup a try and see if it fits your needs
792 Views