I want to draw a little gradient on one of my components, but I specifically want to draw it just outside of the current bounds of my composable, a bit to the right.
I am having trouble getting anything to be drawn outside of my bounds when using
drawWithContent
. Am I typically not allowed to draw outside of my canvas' bounds perhaps?
More details in thread ๐งต
Stylianos Gakis
11/10/2024, 12:12 AM
When I try to do this
Copy code
.drawWithContent {
drawContent()
drawRect(
brush = Brush.horizontalGradient(
colors = listOf(someColor, someOtherColor),
startX = size.width,
endX = size.width + 4.dp.toPx(), // I tried just `4.dp.toPx(),` too but that's not it either.
),
)
}
It seems to sort of "overflow" and just draws the first color over the entire item instead, never painting with any of the
But it can happen in scroll containers or if there's an offscreen graphics layer (or an explicit clip modifier of course)
s
Stylianos Gakis
11/10/2024, 12:45 AM
Yeap, it was not clipping in my scenario at all. It was just be making a mistake there!
Final code looks like this and works just fine rendering outside of the parent composable's content