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

Kazemihabib1996

03/17/2020, 8:30 PM
I've been reading source of Container I found a weird situation If we set
fixedWidth
(maxWidth == minWidth) it sets the containerWidth equal to that with out considering the padding
Copy code
layout(containerWidth, containerHeight) {
    val p = placeable ?: measurables.firstOrNull()?.measure(childConstraints)
    p?.let {
        val position = alignment.align(
            IntPxSize(
                containerWidth - it.width - totalHorizontal,
                containerHeight - it.height - totalVertical
            )
        )
        it.place(
            padding.left.toIntPx() + position.x,
            padding.top.toIntPx() + position.y
        )
    }
}
So it can draw the children outside the container it certain cases for example:
Copy code
Container(modifier = LayoutSize.Constrain(200.ipx.toDp(), 200.ipx.toDp())
        , padding = EdgeInsets(300.ipx.toDp(), 300.ipx.toDp())
                    ) {
                        Button{Text("H")}
                    }
In preview it shows it's drawn outside the container but in real device it doesn't draw the children even when preview shows the children inside the Container but return value of align is negative (position variable).
Copy code
padding = EdgeInsets(300.ipx.toDp(), 300.ipx.toDp(), 300.ipx.toDp(), 300.ipx.toDp())
can create the last situation.