How can I align the text using Text
composable function vertically. Is there a way to do it without having to add another extra view to contain the Text
.
The textAlign
parameter of Text
only has the following options:
TextAlign.
- Left
- Right
- Center
- Justify
- Start
- End
I have tried using textAlign = TextAlign.Center
but it only centers it horizontally. How can I center it vertically without wrapping it in another view?
Text(
text = "Text",
modifier = Modifier.size(100.dp),
textAlign = TextAlign.Center
)
Result:
What I am trying to achieve:
You have to use a parent container and align the composable inside it.
For example a
Box
:or a
Column
: