Is there any way to let compose know that composab...
# compose
r
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
Copy code
Composable1(modifier = Modifier.fillMaxSize(0.5f))
Spacer()
Composable2()
t
that or you can use constraint layout
c
Copy code
Composable1(modifier = Modifier.weight(1f))
Spacer()
Composable2(modifier = Modifier.weight(1f))
having weight set to 1 will make sure both take up 50%
t
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? 🤔
c
Yep, good point. I just wanted to point out that something like
Copy code
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.
t
oh yeah. i always tend to get confused about weights in situations like this 😓