Skip to main content
InterviewHubPRO
Section Overview
Q26

Question 26 of 50

Part 3: ART Internals, Memory Leak Profiling & Production Hardening (25 - 35)

52%
Android & Jetpack Compose (50 Qs)•Part 3: ART Internals, Memory Leak Profiling & Production Hardening (25 - 35)

How do you implement Custom Canvas drawing in Jetpack Compose?

senior LevelCode ExamplePerformanceMemory ManagementDocker & Containers

In Simple Words: When standard Compose layouts are insufficient, use the Canvas composable:

  • Grants access to a DrawScope for hardware-accelerated 2D rendering:
kotlin
@Composable
fun CircularProgress(progress: Float) {
    Canvas(modifier = Modifier.size(100.dp)) {
        drawArc(
            color = Color.Blue,
            startAngle = -90f,
            sweepAngle = 360f * progress,
            useCenter = false,
            style = Stroke(width = 8.dp.toPx(), cap = StrokeCap.Round)
        )
    }
}