rajesh

    rajesh

    1 year ago
    Is there any way to let compose know that composable1() should be placed in upper half of screen and composable2() should be placed in lower half of screen (like instagram profile page), no matter at what time data arrive from network. (post data could arrive before user data)
    Found the solution
    Composable1(modifier = Modifier.fillMaxSize(0.5f))
    Spacer()
    Composable2()
    than_

    than_

    1 year ago
    that or you can use constraint layout
    Colton Idle

    Colton Idle

    1 year ago
    Composable1(modifier = Modifier.weight(1f))
    Spacer()
    Composable2(modifier = Modifier.weight(1f))
    having weight set to 1 will make sure both take up 50%
    Tash

    Tash

    1 year ago
    how much space would Spacer() take in this case? assuming you could give it a static height and it should work well with the two weighted composables? 🤔
    Colton Idle

    Colton Idle

    1 year ago
    Yep, good point. I just wanted to point out that something like
    Composable1(modifier = Modifier.fillMaxSize(0.5f))
    Spacer()
    Composable2(modifier = Modifier.fillMaxSize(0.5f))
    would not work, because I did this yesterday, and so Composable2 will only take up 50% of the rest of the space, which is 25% of the space. So using something like weight might be appropriate.
    Tash

    Tash

    1 year ago
    oh yeah. i always tend to get confused about weights in situations like this 😓