https://kotlinlang.org logo
k

Kshitij Patil

10/27/2020, 6:39 AM
How to center a text?
Copy code
Column(Modifier.fillMaxSize()) {
   Text("Dashboard will be here", Modifier.wrapContentSize(Alignment.Center))
}
is not working
Copy code
Column(
    Modifier.fillMaxSize(),
    verticalArrangement = Arrangement.Center,
    horizontalAlignment = Alignment.CenterHorizontally
)
worked for me. Let me know if there's any better way
c

Chethan

10/27/2020, 6:46 AM
You have to say - Column(Modifier.fillMaxWidth()) {
k

Kshitij Patil

10/27/2020, 6:48 AM
@Chethan I thought
fillMaxSize()
is a combination of both (width and height)
a

alorma

10/27/2020, 6:49 AM
Use
Box
instead of Column
c

Chethan

10/27/2020, 6:49 AM
Even I thought the same , but I am wonder why it doesn’t work
a

alorma

10/27/2020, 6:51 AM
Because column only work with horizontal alignament
Column and Row only expand to it's "negative" axis
Someone explained it better days ago, but can't find the answer now
k

Kshitij Patil

10/27/2020, 6:51 AM
@alorma yup.
Copy code
Box(
    Modifier.fillMaxSize(),
    alignment = Alignment.Center
)
works perfect. Thanks!
4 Views