Othman El Jazouli
06/11/2025, 5:59 PMBox(
modifier = Modifier
.fillMaxWidth()
.background(Color.Red, RoundedCornerShape(16.dp)),
) {
Box(
modifier = Modifier
.fillMaxWidth()
.background(Color.Yellow)
) {
Spacer(modifier = Modifier.size(40.dp))
}
}
or
Surface (
modifier = Modifier
.fillMaxWidth(),
color = Color.Red,
shape = RoundedCornerShape(16.dp),
) {
Box(
modifier = Modifier
.fillMaxWidth()
.background(Color.Yellow)
) {
Spacer(modifier = Modifier.size(40.dp))
}
}
Othman El Jazouli
06/12/2025, 5:54 PM@Composable
private fun Preview() {
Column(
modifier = Modifier
.fillMaxSize()
.background(Color.Yellow)
.padding(20.dp)
) {
Box {
Box(
modifier = Modifier
.size(100.dp)
.background(Color.Red)
)
Box(
modifier = Modifier
.size(100.dp)
.background(Color.Yellow)
)
}
}
}
gives a red square, as if the red square behind is leaking color or the yellow square in front is not 100dp - any clue why compose draws like this?ephemient
06/12/2025, 6:03 PMOthman El Jazouli
06/12/2025, 6:37 PMephemient
06/12/2025, 6:42 PMOthman El Jazouli
06/12/2025, 6:43 PMephemient
06/12/2025, 6:45 PMephemient
06/12/2025, 6:46 PMOthman El Jazouli
06/12/2025, 6:49 PMOthman El Jazouli
06/12/2025, 7:24 PMThomas Hormes
06/13/2025, 5:24 AMOthman El Jazouli
06/13/2025, 7:27 PMOthman El Jazouli
06/17/2025, 7:45 PM// antialiasing fix - 2 overlapping views with solid bg will have artifacts on the edges
// using a mask to show the part that is revealed
.drawWithContent {
withTransform({
clipRect(
top = 0F,
bottom = size.height,
left = size.width - revealedWidth,
right = size.width
)
}) {
this@drawWithContent.drawContent()
}
},