What are differents between fillParentMaxWidth() and fillMaxWidth() in Compose?

Viewed 145

The following Code A is from the official sample project.

It seems that I get the same UI result after I replace the two fillParentMaxWidth() with fillMaxWidth().

What are differents between fillParentMaxWidth() and fillMaxWidth() in Compose?

Code A

@Composable
private fun ExploreList(
    exploreList: List<ExploreModel>,
    onItemClicked: OnExploreItemClicked,
    modifier: Modifier = Modifier,
    listState: LazyListState = rememberLazyListState(),
) {
    LazyColumn(modifier = modifier, state = listState) {
        items(exploreList) { exploreItem ->
            Column(Modifier.fillParentMaxWidth()) {
                ExploreItem(
                    modifier = Modifier.fillParentMaxWidth(),
                    item = exploreItem,
                    onItemClicked = onItemClicked
                )
                Divider(color = crane_divider_color)
            }
        }
        item {
            Spacer(modifier = Modifier.navigationBarsHeight())
        }
    }
}
1 Answers

As here LazyColumn is used fillParentMaxWidth fill be same as fillMaxWidth.

In case of LazyRow, fillMaxWidth will raise an error. So fillParentMaxWidth can be used.

And the other way for LazyColumn.

Related