Hi, I am have cards with shadows inside LazyRow wi...
# compose
k
Hi, I am have cards with shadows inside LazyRow with some horizontal padding. Applying the padding according to our designs, the shadows get cut off on the sides. Only workaround that looks somewhat good is applying the horizontal padding and then a tiny content horizontal padding to the LazyRow. But I feel like there should be better solution to this, which I havent found. Thanks for help.
The code:
Copy code
@Composable
fun TilesWidget(
    modifier: Modifier = Modifier,
    widgetData: TilesWidgetData,
    onTileClick: (TileType) -> Unit
) {
    LazyRow(
        modifier = modifier
            .height(DISPLAYED_TILES_GRID_HEIGHT)
            .padding(horizontal = 16.dp),
        horizontalArrangement = Arrangement.spacedBy(16.dp)
    ) {
        items(widgetData.tiles, key = { it.id }) { tileGroup ->
            LazyColumn(
                modifier = Modifier.fillMaxHeight(),
                contentPadding = PaddingValues(vertical = 8.dp),
                verticalArrangement = Arrangement.SpaceBetween
            ) {
                items(
                    items = tileGroup.tiles
                ) { tile ->
                    DashboardTile(
                        modifier = Modifier
                            .ifThen(tile.tileType.isFunctionType()) {
                                Modifier.fillParentMaxHeight()
                            },
                        tileType = tile.tileType,
                        onClick = onTileClick
                    )
                }
            }
        }
    }
}
s
Have you tried using contentPadding on the LazyColumn?
k
I did, but that does not unfortunately solve my problem. I need the whole container (lazyrow) to be padded by 16.dp and using content padding pads the first and last item. If there are more items in the lazy row and they go over screen width, using only content padding will make the content go over the supposed padding cut off I am aiming for (hope that makes sense :D). Thanks though 👍
s
Does your
DashboardTile
set its own background color? How does the shadow look if you remove that?
k
Its a Material 3 Card and I set its color via CardDefaults.cardColors(containerColor=...). I'll try to remove it and report back 👍
z
You should be able to apply the padding to each card and it will work. A bit more tedious w/ spacing between them, but I always end up having to move padding into cards since not all items in my lists will want to have padding applied to them!