Drawing gradient border or text color as gradient is quiet cumbersome task with Android Java or Kotlin, with Jetpack compose its a very simple and straight forward which can be accomplished with very steps.
Here is how it can be down to draw a gradient border and gradient text color.
Gradient Border Color
Image(
painter = painterResource(user.avatar),
contentDescription = user.name,
modifier = Modifier
.size(80.dp)
.clip(RoundedCornerShape(40.dp))
.border(
1.dp,
brush = Brush.verticalGradient(gradient01),
shape = RoundedCornerShape(40.dp)
),
)
Output
Gradient Text Color
Text(
text = "saharakks",
style = TextStyle(
brush = Brush.verticalGradient(gradient01),
fontWeight = FontWeight.Bold
),
modifier = Modifier
.padding(10.dp)
)