Alright I figured it out:
First, add a
graphicsLayer
modifier with
CompositingStrategy.Offscreen
to the parent composable (in this case, the
LazyVerticalGrid
):
LazyVerticalGrid(
...,
modifier = Modifier
.graphicsLayer(compositingStrategy = CompositingStrategy.Offscreen)
...
)
Then you can apply
BlendMode.Clear
on the child composable, and it'll only clear all the way up to the parent, because the parent created a separate graphics layer:
YourChildComposable(
...,
modifier = Modifier
.drawWithContent { // if you don't care about the content, you could use drawBehind instead, or use a Canvas directly.
drawRect(Color.Black, blendMode = BlendMode.Clear)
drawContent() // only if you want to keep content (e.g. some overlay), if any.
}
...
)
That'll achieve the desired behavior.