Skip to content

Instantly share code, notes, and snippets.

@dineshvg
Created September 22, 2023 07:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dineshvg/14ba2df3357f68d6b2ec529992eb90c5 to your computer and use it in GitHub Desktop.
Save dineshvg/14ba2df3357f68d6b2ec529992eb90c5 to your computer and use it in GitHub Desktop.
DrawWithContent vs DrawBehind
@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