Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make transparent background in Box jetpack compose

I want to make transparent color of Box in jetpack compose. I tried but it makes white background. Can someone guide me on this?

@Composable
fun OnContentLoading() {
    Box(
        modifier = Modifier
            .fillMaxSize()
            .background(Color.Transparent)
    ) {
        CircularProgressIndicator(
            modifier = Modifier.align(Alignment.Center),
            color = Aqua
        )
    }
}

@Preview(showBackground = true)
@Composable
fun PreviewOnContentLoading() {
    OnContentLoading()
}

Output

enter image description here

like image 462
Vivek Modi Avatar asked Dec 29 '25 04:12

Vivek Modi


1 Answers

background(Color.Transparent)

This or Color.Unspecified draws nothing but Color(0x00000000)

for a transparent background you need to set first two digits between 01 and ff and other six digits are RRGGBB basically it's AARRGGBB

like image 50
Thracian Avatar answered Dec 31 '25 18:12

Thracian