https://kotlinlang.org logo
#compose
Title
# compose
f

Florian

12/06/2021, 8:38 PM
Any idea why my card shadows are clipped off? I seem to not do anything special (code in the thread)
Copy code
@Composable
private fun TaskItem(
   [...]
) {
    Card(
        shape = RoundedCornerShape(Dimens.DefaultCardRoundedCornerSize),
        elevation = Dimens.DefaultCardElevation,
        modifier = modifier
            .fillMaxWidth()
            .padding(top = 12.dp)
            .animateContentSize(),
        onClick = { onTaskClicked(task) }
    ) {
        Column {
        [...]
    }
if I remove
animateContentSize
the shadows appear but only on the bottom, not on the sides
s

Stylianos Gakis

12/06/2021, 9:11 PM
If you look inside the
animateContentSize
implementation you will see that it puts a clip modifier to the contents by itself and it’s not configurable for reasons explained by Doris Liu here: https://kotlinlang.slack.com/archives/CJLTWPH7S/p1638385104410200?thread_ts=1638375155.392500&cid=CJLTWPH7S I had the exact same problem and I fixed it simply by doing what she said, put that modifier on the only child of the card, and put all my composables inside that child instead. I just did it with a plain
Box
but anything should work, you can put it on your
Column
I guess since I see you have it there already.
f

Florian

12/06/2021, 9:28 PM
Thank you, this actually solved severarl other problems I had as well 😁
the animation looked weird when I had the modifier on the card and scrolling also had some weird effects
now it's perfect
🎉 1
s

Stylianos Gakis

12/06/2021, 9:29 PM
I am happy to hear that!
f

Florian

12/06/2021, 9:29 PM
I don't have shadows on the start/end but I'm not sure if there are supposed to be any 🤔
s

Stylianos Gakis

12/06/2021, 9:29 PM
When in doubt, add an elevation of 20.dp and you’ll know if it’s there or not 😅
f

Florian

12/06/2021, 9:30 PM
good idea
🧠 1
ill double check my layout
👌 1
thank you again
🙏 1
ok now it works, I had a clip and a padding in the wrong order