Sulav Timsina
08/08/2024, 2:32 PMStylianos Gakis
08/08/2024, 3:01 PMSulav Timsina
08/08/2024, 3:15 PMRow {
Icon(
modifier = Modifier.size(MyTheme.dimensions.medium),
painter = painterResource(id = drawable),
tint = animatedColor.value,
contentDescription = null,
)
Spacer(modifier = Modifier.width(MyTheme.dimensions.tiny))
Text(
modifier = Modifier.align(Alignment.CenterVertically),
style = MaterialTheme.typography.bodySmall,
text = rule.copy,
color = animatedColor.value,
)
}
@Stylianos Gakis This is how it is now.Stylianos Gakis
08/08/2024, 3:22 PMmodifier = Modifier.size(MyTheme.dimensions.medium),
and replace it with
modifier = Modifier.size(MyTheme.dimensions.medium).align(Alignment.CenterVertically),
But you could also not do that in the individual items and instead do
Row(verticalAlignment = Alignment.CenterVertically) { ...
So this alignment applies to all items inside that row.
And tbh that's even better since perhaps the icon can also grow bigger than the textSulav Timsina
08/08/2024, 3:28 PMSulav Timsina
08/08/2024, 3:29 PM.align(<http://Alignment.Top|Alignment.Top>)
this is how it looks:Stylianos Gakis
08/08/2024, 3:32 PMSulav Timsina
08/08/2024, 3:32 PMephemient
08/08/2024, 3:34 PMStylianos Gakis
08/08/2024, 3:34 PMfun Modifier.withoutPlacement(): Modifier = this.layout { measurable, constraints ->
val boxPlaceable = measurable.measure(constraints)
layout(width = boxPlaceable.width, height = boxPlaceable.height) {}
}
I have on a row somehthing like this:
Row {
Box(contentAlignment = Alignment.Center) {
Text("H", modifier = Modifier.withoutPlacement)
Icon(your icon here)
}
Text("Your long text here")
}
ephemient
08/08/2024, 3:34 PMephemient
08/08/2024, 3:35 PMStylianos Gakis
08/08/2024, 3:37 PMStylianos Gakis
08/08/2024, 3:38 PMSulav Timsina
08/08/2024, 3:42 PMStylianos Gakis
08/08/2024, 3:43 PMsindrenm
08/08/2024, 5:52 PMText("H")
or if it's ignored because it's not placed. Do you know?Stylianos Gakis
08/08/2024, 6:18 PMsindrenm
08/08/2024, 6:26 PMSulav Timsina
08/08/2024, 6:30 PMStylianos Gakis
08/08/2024, 6:31 PM