How to place a Text in center in latest update dev...
# compose
s
How to place a Text in center in latest update dev 09 version? There is no composable function Center(deprecated). Please help if anyone can...
🎉 1
z
You need to use a modifier:
Text(…, modifier = Modifier.wrapContentSize(Alignment.Center))
a
You can try
Copy code
Box(gravity = ContentGravity.Center) {
    Text(...)
}
Yes, in case Text better to use modifier, but in case of multiple
@Composable
function you can use Box
s
still showing un top left
@alexzhukovich @Zach Klippenstein (he/him) [MOD] still showing top left of display
i want to show it on the center of display as Center is deprecated in latest version.
l
you probably also want
Modifier.fillMaxWidth()
or something similar so that it is centering across the full width that you are wanting
a
The following code is working for me:
Copy code
Text(
    text = "abc",
    modifier = Modifier.fillMaxWidth() + Modifier.wrapContentSize(Alignment.Center)
)
s
@alexzhukovich are you using latest dev09 version?
a
yes
Could you share your code?
s
hey i found the solution: Text(modifier=Modifier. fillMaxSize() +Modifier. wrapContentSize(Alignment. Center))
@alexzhukovich Thanks for help.
a
Just
Modifier.fillMaxSize().wrapContentSize(Alignment.Center)
, it's cleaner 🙂
but yes, the above is identical to the behavior of the old
Center
composable wrapper