I'm having some sort of learner moment. I'm trying...
# compose
t
I'm having some sort of learner moment. I'm trying to place a translucent scrim over some slot contents. To wit:
Copy code
Box(modifier = modifier) {
   content()
   if (isUnresponsive) {
      Box(modifier = Modifier
         .height(IntrinsicSize.Max).width(IntrinsicSize.Max).fillMaxWidth().fillMaxSize()
         .background(Color.Green.copy(alpha = 0.5f)).align(Alignment.TopCenter)
...
But I cannot for the life of me get that inner box to show up, layering over the content(). Oddly a BottomCentered Row as a footer that comes right after that Box shows up just fine. I've put some logging statements on a globallyPositioned modifier, and it always reports a zero rect. I'm obviously throwing every "just fill the parent bounds, OK?" modifier at it there. But the contentless box just doesn't measure/layout. What's the headsmack I'm missing?
m
use height(IntrinsicSize.Max).width(IntrinsicSize.Max) in the parent box. and fillMaxSize in the scrim box. try it
t
That caused the overlay to show up... but screwed up the content() compositions...
m
Content should have a modifier
t
My content is a Column with a fillMaxWidth modifier. It no longer fills the max width now. Or do you mean that the content() function was supposed to take a single argument?
m
Without the full code its hard. You can also try: drawWithContent drawContent drawRect(color) modifier in the content itself
That way you dont need a fake box
t
does drawWithContent clip to the layout bounds?
m
Its a way to dra above or behind. If you just need overlay color its the best option