https://kotlinlang.org logo
#compose
Title
# compose
a

Alexander Black

03/26/2022, 1:29 AM
Wondering if anyone has any advice on how I can do an overlay like this? I currently have it working using this code:
Copy code
overlay = {
                    if (it.isSelected) {
                        Box(
                            Modifier
                                .size(if (it.rentalLength != null) 245.dp else 222.dp)
                                .alpha(0.6f)
                                .background(DownpourTheme.colors.primary)
                        )
                    }
                }
            )
but the size being hardcoded is obviously not ideal. Wondering if there’s an easy way to measure the size of the card my box is trying to overlay?
c

Chris Sinco [G]

03/26/2022, 5:40 AM
Have you tried using the drawBefore modifier which can draw a rectangle over content of a Composable?
a

Alexander Black

03/26/2022, 1:47 PM
I have not! I will give that a go. Thank you very much for the suggestion. 👌🎉
For some reason I’m not finding the drawBefore modifier. Could you link me to the docs? @Chris Sinco [G]
c

Chris Sinco [G]

03/26/2022, 4:06 PM
a

Alexander Black

03/31/2022, 8:57 PM
@Chris Sinco [G] Finally got around to trying your suggestion. Worked like a dream! thank you so much! What a great tool!
🎉 1
2 Views