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

Tash

03/07/2022, 4:17 AM
Trying to draw
Text
with a horizontal gradient. After much trial and error, found that this works only if I specify
alpha = 0.99f
in the
graphicsLayer
(output in 🧵) Can someone explain why? 😖
Copy code
Text(
    text = "$ 20",
    modifier = Modifier.graphicsLayer(alpha = 0.99f)
        .drawWithCache {
            val brush = Brush.horizontalGradient(listOf(StartColor, EndColor))
            onDrawWithContent {
                drawContent()
                drawRect(brush, blendMode = BlendMode.SrcAtop)
            }
        },
)
👍 1
output
t

Tash

03/07/2022, 7:03 AM
Oh wow, I thought I was going crazy! Thanks 😅
👍 2
c

Colton Idle

06/29/2022, 4:40 PM
@Tash how'd this end up working for you. I got some acceptance criteria to build this out today and wanted to give your code a shot.
c

Colton Idle

06/29/2022, 7:32 PM
oh wayyy cool. repo. love the pokemon card!
🙏🏼 1
😅 1
6 Views