h

    Hackdiod

    2 years ago
    Hello! Do you now, how use Center item for few elements. I have Row>Column2>Text4, but Row>Column2>Center>Column>Text4 it works incorrectly. I think use Center to each text is the wrong approach.
    Mihai Popa

    Mihai Popa

    2 years ago
    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

    Hackdiod

    2 years ago
    Thank you for your replay! If I use
    Text("Test", modifier = Gravity.Center)
    it's Ok, but I think if I will use this construction:
    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:
    Column(modifier = Gravity.Center) {
    Text("Test1")
    Text("Test2")
    Text("Test3")
    Text("Test4")
    }
    it's not working for me.