简体   繁体   中英

Card element with shadow only on the bottom

I am trying to create Card element and to add shadow only on bottom part with a little bit in left and right and zero on the top.

 Card(
    elevation = 10.dp,
    modifier = Modifier
        .background(color = seatfrogWhite, shape = RoundedCornerShape(4.dp))
        .graphicsLayer {
            this.shadowElevation = 10.dp.toPx()
            this.shape = RoundedCornerShape(4.dp)
            this.clip = true
        }
        .height(50.dp)
        .width(100.dp),
    shape = RoundedCornerShape(4.dp)
) {}

I have tried with shadow() modifier, but without success. It always add shadow on the top.

You can use the M3 ElevatedCard :

ElevatedCard(
    Modifier.size(width = 180.dp, height = 50.dp),
    shape = RoundedCornerShape(4.dp),
    elevation = CardDefaults.elevatedCardElevation(8.dp),
    colors = CardDefaults.elevatedCardColors(containerColor = Teal200),
) {
    // Card content
}

在此处输入图像描述

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM