This question notes that in order to not clip the shadows on a LazyRow/LazyColumn in Jetpack Compose you need to add ContentPadding. However, I want to do the equivalent of "clipToPadding=false" without adding additional padding (the padding should be 0.dp). Is this possible? Or do you have to have some sort of 1.dp padding around the object?
Ex:
LazyRow(
state = listState,
flingBehavior = flingBehavior,
contentPadding = PaddingValues(all = 0.dp)
)
See clipping shadows on the lefthand edge:

LazyRow(
state = listState,
flingBehavior = flingBehavior,
contentPadding = PaddingValues(horizontal = 0.dp)
) {
items(itemsList) { item ->
Box(
modifier = Modifier
.padding(horizontal = 8.dp) // add small padding to each item
.drawWithContent {
drawContent() // draw the content
drawRect(
color = Color.Black, // define your shadow color
size = Size(size.width, 16f), // adjust shadow size
style = Shadow(style = ShadowStyle.Cut), // set the shadow style
shape = RectangleShape, // use a shape
topLeft = Offset(x = 0f, y = size.height - 16f) // set shadow offset
)
}
) {
// your content
}
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With