Given the following androidx.compose.material3.ListItem code snippet ...
ListItem(
leadingContent = {
LeadingIcon()
},
trailingContent = {
TrailingIcon()
},
overlineText = {
Text(
text = item.text,
)
},
headlineText = {
Text(
text = item.title,
overflow = Ellipsis,
maxLines = 1,
)
},
supportingText = {
if (item.subtitle.isNotEmpty()) {
Text(
text = item.subtitle,
overflow = Ellipsis,
maxLines = 1,
)
}
}
)
Is there a way to vertically center the leading and trailing content/icons?
It would also be desired that the item shrinks its height if no subtitle is given. The icons should then still be centered.
I don't think this looks the best, but you could try setting two fixed heights for the content with
item.subtitleand withoutitem.subtitle, and wrap theIconin aColumnand set the alignment to center: