Android Jetpack Compose: shadow doesn't showing properly for dark content

573 Views Asked by At

I'm trying to show a shadow in a Card, Surface or any container, but the shadow is not showing with dark content. Doesn't matter: black color or internal dark image. Tried changing the shadow color to red and found that the intensity of the shadow decreases as the dark content increases.

How to show full shadow for dark content?

@Preview
@Composable
fun TestComposable() {
    Column(
        Modifier
            .fillMaxSize()
            .background(color = Color.White)) {
        ShadowCardView(Color.Black)
        ShadowCardView(Color.DarkGray)
        ShadowCardView(Color.White)
    }
}

@Composable
fun ShadowCardView(color: Color) {
    val shape = RoundedCornerShape(15.dp)
    Surface(
        modifier = Modifier
            .padding(start = 50.dp, top = 50.dp)
            .width(200.dp)
            .height(100.dp)
            .shadow(
                elevation = 20.dp,
                spotColor = Color.Red,
                ambientColor = Color.Red,
                shape = shape
            ),
        shape = shape,
        color = color,
    ) {}
}

enter image description here enter image description here

1

There are 1 best solutions below

0
Rustam Samandarov On

It seems like a bug.

You can try to change color order from white to black.

The next element is being drawn with bolder shadows.

enter image description here