how to change text color Opacity in jetpack compose

Viewed 1321

how can i change the opacity of Text Color.White in JetPack Compose

Text(text = funfact , fontSize = 18.sp, color = Color.White )
2 Answers

You can change the alpha channel from the Color attribute:

Text(text = funfact, fontSize = 18.sp, color = Color.White.copy(alpha = 0.5f))

You can also user the alpha modifier :

Text(
    text = funfact,
    modifier = Modifier.alpha(0.5f),
    fontSize = 18.sp,
    color = Color.White,
)
Related