https://kotlinlang.org logo
#compose
Title
# compose
o

Orhan Tozan

03/09/2021, 2:47 PM
Why does the inner column not fill the whole screen? Code below results in whole screen being blue, but only a little bit red (height of the text). I would expect the inner column to fill the whole screen (and thus make the whole screen red).
Copy code
Column(modifier = Modifier.fillMaxHeight().background(Color.Blue)) {
    Column(modifier = Modififer.fillMaxHeight().background(Color.Red)) {
        Text("Hi")
    }
}
t

Timo Drick

03/09/2021, 2:56 PM
Maybe you want to use Box for the outer Column?
Inside a Column you should use weight(1f) to get the full height Of course it depends on how many items you have in a Column. Because a Column is a column 😄
o

Orhan Tozan

03/09/2021, 3:00 PM
@Timo Drick let's say the inner column has two text's above him (two siblings). Now I want the inner column to fill the remaining height. How would that happen?
t

Timo Drick

03/09/2021, 3:03 PM
just use the Modifier.weight(1f)
o

Orhan Tozan

03/09/2021, 3:53 PM
Thanks Timo it works. Guess it's still kind of a trap that Modifier.fillMaxHeight() exists for the column while it doesn't do anything
a

Albert Chang

03/09/2021, 11:53 PM
Modifier.fillMaxHeight()
in a
Column
definitely works. I copied your code and it's working as expected. You must have something else wrong.
3 Views