I want to align each item in a column one by one. I believe it's possible in simple Column using align operator like that:
Column {
Text(text = "First", modifier = Modifier.align(Alignment.Start))
Text(text = "Second", modifier = Modifier.align(Alignment.End))
Text(text = "Third", modifier = Modifier.align(Alignment.Start))
}
However I cannot find align operator for LazyColumn in appropriate scopes. How to do it in LazyColumn? I'm not interested in horizontalAlignment as it applies to all items.
You can wrap each item in a Box and then apply alignment within the Box.
Box(modifier = Modifier.fillMaxWidth()) {
Text(text = "First", modifier = Modifier.align(Alignment.TopCenter))
}
Another solution is to use 2 modifier attributes:
Text(
text = "Your text here",
modifier = Modifier
.fillMaxWidth()
.wrapContentWidth(align = Alignment.CenterHorizontally),
)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With