Ux question: When I have list of of items (usually...
# compose
t
Ux question: When I have list of of items (usually clickable) to show, I just emit items with a desired amount of vertical padding. I know that the space between items will then by 2 x gap, and the gap from the bottom/top of the last will just be 1 x gap. Someone working with me coming from web design had different ideas about padding/margin, etc. And feels that the gap at the top/bottom should be the same as that between items. I could easily acheive this by using new padding on the items, but instead emiting N + 1 vertical Spacers. Or I could do something really distasteful, and still use padding, but use different values for the first and last elements. What do others do? (this is in particular when placing cards in lists)
s
Could you just use something like
verticalArrangement = Arrangement.spacedBy(<desired padding>)
☝️ 1
if you want different padding for the top and bottom that different than the spacing between elements, in the past I just adjusted the padding on the parent.
Copy code
Column(
   horizontalAlignment = Alignment.CenterHorizontally,
   modifier = Modifier.padding(vertical = 10.dp, horizontal = 20.dp).background(color =MaterialTheme.colorScheme.onSecondaryContainer, shape = MaterialTheme.shapes.small).padding(10.dp),
   verticalArrangement = Arrangement.spacedBy(15.dp)
) {
This column would space its child elements by 15 but also pad the first element 10 from the top and the last 10 from the bottom
☝️ 1