https://kotlinlang.org logo
Title
t

Travis Griggs

04/20/2023, 4:08 PM
I'm having some sort of learner moment. I'm trying to place a translucent scrim over some slot contents. To wit:
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

myanmarking

04/20/2023, 5:04 PM
use height(IntrinsicSize.Max).width(IntrinsicSize.Max) in the parent box. and fillMaxSize in the scrim box. try it
t

Travis Griggs

04/20/2023, 5:18 PM
That caused the overlay to show up... but screwed up the content() compositions...
m

myanmarking

04/20/2023, 5:20 PM
Content should have a modifier
t

Travis Griggs

04/20/2023, 5:26 PM
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

myanmarking

04/20/2023, 5:29 PM
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

Travis Griggs

04/20/2023, 5:31 PM
does drawWithContent clip to the layout bounds?
m

myanmarking

04/20/2023, 5:41 PM
Its a way to dra above or behind. If you just need overlay color its the best option