Created
September 22, 2023 07:33
-
-
Save dineshvg/14ba2df3357f68d6b2ec529992eb90c5 to your computer and use it in GitHub Desktop.
DrawWithContent vs DrawBehind
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Preview | |
@Composable | |
fun DrawBefore() { | |
Box( | |
modifier = Modifier.fillMaxSize(), | |
contentAlignment = Alignment.Center | |
) { | |
Card( | |
shape = RoundedCornerShape(8.dp) | |
,modifier = Modifier | |
.size(100.dp) | |
.drawWithContent { | |
drawContent() | |
drawCircle(Color(0xffe7614e), 18.dp.toPx() / 2, center = Offset(drawContext.size.width, 0f)) | |
} | |
) { | |
Image(painter = painterResource(id = R.drawable.diana), contentDescription = "Diana") | |
} | |
} | |
} | |
@Preview | |
@Composable | |
fun DrawBehind() { | |
Box( | |
modifier = Modifier.fillMaxSize(), | |
contentAlignment = Alignment.Center | |
) { | |
Card( | |
shape = RoundedCornerShape(8.dp) | |
,modifier = Modifier | |
.size(100.dp) | |
.drawBehind { | |
drawCircle(Color(0xffe7614e), 18.dp.toPx() / 2, center = Offset(drawContext.size.width, 0f)) | |
} | |
) { | |
Image(painter = painterResource(id = R.drawable.diana), contentDescription = "Diana") | |
} | |
} | |
} | |
// https://compose.funnysaltyfish.fun/docs/design/graphics/customDraw |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment