AndroidDev
AndroidDev

Reputation: 41

Remove Card shadow from bottom in compose

Is there anything by which i can remove shadow from bottom of Card.


` Card(
        modifier = modifier
            .shadow(elevation = 0.dp, spotColor = Color.Transparent, shape = shape),
        elevation = 16.dp,
            shape = shape,
            backgroundColor = MaterialTheme.colors.surface
        )`

I kept elevation as 16.dp, due to which i got shadow around card. i dont want to set shadow in bottom. is there any option to do so?

Upvotes: 2

Views: 719

Answers (1)

Jakub Kostka
Jakub Kostka

Reputation: 895

You can clip the Composable with Modifier.clip(shape) as following:

            Card(
                modifier = modifier
                    .clip(shape = shape)
                    .shadow(elevation = 0.dp, spotColor = Color.Transparent, shape = shape),
                elevation = 16.dp,
                shape = shape,
                backgroundColor = MaterialTheme.colors.surface
            )

This works whenever you set shadow manually, without the elevation on card, as you set the boundaries for the following Modifier - meaning you put the clip modifier before any other, in our case the shadow Modifier.

Upvotes: 1

Related Questions