:wave: qq: Is there a way to display a repeating b...
# compose
f
👋 qq: Is there a way to display a repeating background in compose? Something similar to “tileMode=repeat”
âž• 1
r
If it's an image, you can draw it on the composable's background in anyway you want using
Modifier.drawBehind
f
Thanks, didn’t know about
drawBehind
I’m still not sure how to set the
canvas
to repeat the image 🤔
Okay, your solution kinda worked for me in the end 🙂 (since I only wanted a dotted background)…
Copy code
for (x in 0..this.size.width.roundToInt() step 80) {
                for (y in 0..this.size.height.roundToInt() step 80) {
                    drawCircle(
                        color = Color.Black,
                        center = Offset(x.toFloat(), y.toFloat()),
                        radius = 8f,
                        alpha = .1f
                    )
                }
            }
r
A quick example of a horizontal repeat
đź’Ż 1
f
nice, yes, this works, not sure how expensive it is (in terms of performance) but is good enough for me right now
n
The tile mode APIs are available as part of the ImageShader API. You can create a brush from that and draw a rectangle with the desired pattern