Home > Software engineering >  How to make transparent background in Box jetpack compose
How to make transparent background in Box jetpack compose

Time:01-10

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

CodePudding user response:

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

  • Related