Can someone help me confirm this bug (on Android, at least)? Using a
requiredSize
that's greater than the parent unexpectedly causes the child to be centered.
If the
Box
is smaller, it's placed at the top left. But if it's greater, it's centered (i.e., you can't see the yellow anymore). See the pictures.
@Preview("Test", device = "spec:width=500dp,height=500dp,dpi=240")
@Composable
private fun ReproPreview() {
val colorStops = arrayOf(
0.0f to Color.Yellow,
0.2f to Color.Red,
1f to Color.Blue
)
BoxWithConstraints(
modifier = Modifier.fillMaxSize(),
contentAlignment = Alignment.TopStart
) {
Box(
modifier = Modifier
.background(Brush.horizontalGradient(colorStops = colorStops))
.requiredSize(height = maxHeight * 2, width = maxWidth * 2)
// Also happens with `offset`
.absoluteOffset(0.dp, 0.dp)
)
}
}