Hello, anyone knows how to align center a Text wit...
# compose
l
Hello, anyone knows how to align center a Text with more than 1 line? With 1 line it is align center horizontally correctly, but with more no
This is my code:
Copy code
Column (modifier = Modifier.weight(1.0f, true)) {
    Image(
        image,
        Modifier
            .preferredSize(56.dp, 56.dp)
            .gravity(Alignment.CenterHorizontally)
    )
    Text(
        modifier = Modifier.gravity(Alignment.CenterHorizontally),
        text = itemTitle,
        style = MaterialTheme.typography.body1,
        maxLines = 3
    )
}
l
Copy code
Text(
    text = itemTitle,
    style = MaterialTheme.typography.body1.copy(textAlign = TextAlign.Center)
)
Should work
gravity
is for layout alignment, it won't affect how the text inside the
Text
are aligned
l
wow thanks 😄