lesincs
11/25/2021, 12:03 AMitem of LazyColumn fill the reset of the height? See thread.lesincs
11/25/2021, 12:09 AMLazyColumn(modifier = Modifier.fillMaxSize()) {
item {
Spacer(
modifier = Modifier
.background(Color.Red)
.fillMaxWidth()
.height(80.dp)
)
}
item {
Spacer(
modifier = Modifier
.background(Color.Green)
.fillParentMaxSize()
)
}
}
In the code below, I want to make the second item with green background fill the reset height of the LazyColumn.
I tried use Modifier.fillMaxSize(), but it didn’t work in LazyColumn, then I tried Modifier.fillParentMaxSize, which is only in LazyItemScope, but it did not work either, the effect is the second item’s height will be as same as the whole LazyColumn. So I want to know is there are some elegant ways to do this? I tried some tricky way like use the Modifier.onSizeChanged , and did some calculation, it works, but the code is terrible. And Why I used a LazyColumn instead of a normal Column is that there are some hidden logic, basically the second item is loading section which I want to centralize the loading indicator,so I need to it fill the rest height.Csaba Kozák
11/25/2021, 9:23 AMfillParentMaxSize()
has a fraction parameter, but i am afraid you have to calculate the size of the normal elements so your loader only takes the rest of the list height.Andrey Kulikov
11/26/2021, 10:02 PM