Hello! Do you now, how use Center item for few ele...
# compose
h
Hello! Do you now, how use Center item for few elements. I have Row>Column*2>Text*4, but Row>Column*2>Center>Column>Text*4 it works incorrectly. I think use Center to each text is the wrong approach.
m
Note that Center will fill the available space, and will center its child inside. So if you use it for a child of a Column, it will fill the available space before further siblings can occupy space. What behavior are you trying to achieve? Take a look at LayoutGravity modifiers, they provide alignment without the fill available space behavior
(also note that Center will be deprecated/removed, you should rather use the LayoutAlign.Center modifier)
h
Thank you for your replay! If I use
Copy code
Text("Test", modifier = Gravity.Center)
it's Ok, but I think if I will use this construction:
Copy code
Text("Test1", modifier = Gravity.Center)
Text("Test2", modifier = Gravity.Center)
Text("Test3", modifier = Gravity.Center)
Text("Test4", modifier = Gravity.Center)
it's not optimal for code. But If I use:
Copy code
Column(modifier = Gravity.Center) {
Text("Test1")
Text("Test2")
Text("Test3")
Text("Test4")
}
it's not working for me.