https://kotlinlang.org logo
Title
t

Tgo1014

07/12/2022, 9:39 AM
is there a way to tint a drawable with a gradient?
l

Leon Turpin

07/12/2022, 9:42 AM
We use this to add a dark bottom edge to anything that takes a modifier. It might be what you’re after
fun Modifier.vDarkBottomBackgroundGradient(): Modifier {
    return this.drawWithContent {
        drawContent()
        drawRect(
            brush = Brush.verticalGradient(
                0.45f to Color.Black.copy(alpha = 0.1f),
                1.00f to Color.Black.copy(alpha = 0.5f),
            ),
            blendMode = BlendMode.Darken
        )
    }
}
There’s plenty of blend modes to play with: https://developer.android.com/reference/android/graphics/BlendMode
There’s plenty of blend modes to play with: https://developer.android.com/reference/android/graphics/BlendMode
t

Tgo1014

07/12/2022, 10:39 AM
Thanks, unfurtunately it's causing some strange colors for me when trying different blendModes. I guess I'll just ask the designers to make it for me lol