mmaillot

    mmaillot

    1 year ago
    How can I do that with compose ?
    Column(modifier = Modifier.fillMaxHeight(), verticalArrangement = Arrangement.SpaceBetween) {
            Header()
            Content()
            Bottom()
        }
    I have this code for the whole screen. In my
    Content
    component, I have the 6 squares which are well aligned with
    SpaceAround
    .
    Column(
            modifier = Modifier.fillMaxWidth(),
            verticalArrangement = Arrangement.SpaceAround,
        ) {
            Row(
                horizontalArrangement = Arrangement.SpaceAround,
                modifier = Modifier.fillMaxWidth(),
            ) {
                Square()
                Square()
                Square()
            }
            Row(
                horizontalArrangement = Arrangement.SpaceAround,
                modifier = Modifier.fillMaxWidth(),
            ) {
                Square()
                Square()
                Square()
            }
        }
    I want the green part to take all place between Header (fixed height) and ProgressBar (fixed height too).
    Timo Drick

    Timo Drick

    1 year ago
    Just add to the green Column a modifier.weight(1f)
    mmaillot

    mmaillot

    1 year ago
    I don’t have the weight function 😕
    Timo Drick

    Timo Drick

    1 year ago
    it is only available inside of a Row or Column
    In your case it should be there. Are you sure it is not there? Just try to type it without auto completion.
    Column {
       Row { //top bar }
       Column(Modifier.weight(1f)) {
           //Green boxes
       }
    mmaillot

    mmaillot

    1 year ago
    I have this code :
    Column(
            modifier = Modifier.weight(1f).fillMaxWidth(),
            verticalArrangement = Arrangement.SpaceAround,
        ) {
            ...
        }
    But failed to compile
    Expression 'weight' cannot be invoked as a function.
    Timo Drick

    Timo Drick

    1 year ago
    Column(modifier = Modifier.fillMaxHeight(), verticalArrangement = Arrangement.SpaceBetween) {
            Header()
            Column(Modifier.weight(1f).fillMaxWidth()) {
                ...
            }
            Bottom()
        }
    It is the same like in the old LinearLayout weight.
    s

    Se7eN

    1 year ago
    You need a
    ColumnScope
    to use it. You'll have to pass
    Modifier.weight(1f)
    to your
    Content
    function or write your
    Content
    function as
    fun ColumnScope.Content()
    Column(modifier = Modifier.fillMaxHeight(), verticalArrangement = Arrangement.SpaceBetween) {
            Header()
            Content(modifier = Modifier.weight(1f))
            Bottom()
        }
    
    @Composable fun Content(modifier: Modifier) {
        Column(modifier = modifier) {
            ...
        }
    }
    mmaillot

    mmaillot

    1 year ago
    Ok, thank you both ! It works 🙂 👍