What is the difference between Modifier.width(intrinsicSize.Min/Max) and Modifier.wrapContentWidth?

Viewed 22

When I use XML and use the wrap_content parameter it is clear to me what its purpose is, the content of the parent is adjusted to whatever the child contains, but I see that this is not exactly the case in Compose.

    Surface(
        Modifier
            .fillMaxWidth()
            .height(IntrinsicSize.Min)
            .clip(RoundedCornerShape(topStartPercent = 8, topEndPercent = 8))
            .constrainAs(surface) {
                bottom.linkTo(parent.bottom)
            },
        color = Color.White
    ) {
        Column(
            Modifier.fillMaxSize(),
            verticalArrangement = Arrangement.Center
        )
    }

In this case it does act as we know the wrap_content in XML, the parent matches what the child contains and thus sets its height. But:

    Surface(
        Modifier
            .fillMaxWidth()
            .wrapContentHeight
            .clip(RoundedCornerShape(topStartPercent = 8, topEndPercent = 8))
            .constrainAs(surface) {
                bottom.linkTo(parent.bottom)
            },
        color = Color.White
    ) {
        Column(
            Modifier.fillMaxSize(),
            verticalArrangement = Arrangement.Center
        )
    }

In this case what happens is that the parent container (in this case the Surface), takes the entire height of the screen, why does this happen and what is the difference?

0 Answers
Related