Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to change text color Opacity in jetpack compose

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

Text(text = funfact , fontSize = 18.sp, color = Color.White )
like image 211
Gnanesh023 Avatar asked Feb 01 '26 11:02

Gnanesh023


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))
like image 97
Stephen Vinouze Avatar answered Feb 03 '26 02:02

Stephen Vinouze


You can also use the alpha modifier:

Text(
    text = funfact,
    modifier = Modifier.alpha(0.5f),
    fontSize = 18.sp,
    color = Color.White,
)
like image 32
bwt Avatar answered Feb 03 '26 01:02

bwt