1

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

Kotlin Learner
  • 3,995
  • 6
  • 47
  • 127
  • Your code is working correctly. There's just nothing in the background. If you put this transparent box inside another box filled with some color, you will see that everything is displayed correctly. – bylazy Jan 09 '23 at 18:35

1 Answers1

1
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

Thracian
  • 43,021
  • 16
  • 133
  • 222