Complete the code to create a custom View class that overrides the onDraw method.
class MyView(context: Context) : View(context) { override fun [1](canvas: Canvas) { super.onDraw(canvas) } }
The onDraw method is the correct method to override for custom drawing in a View.
Complete the code to create a Paint object with red color.
val paint = Paint().apply {
color = [1]
style = Paint.Style.FILL
}To draw in red, set the paint color to Color.RED.
Fix the error in the code to draw a circle at position (100, 100) with radius 50.
canvas.[1](100f, 100f, 50f, paint)
The drawCircle method draws a circle with given center coordinates and radius.
Fill both blanks to draw a blue rectangle from (50, 50) to (200, 150).
val rect = RectF([1], 50f, [2], 150f) canvas.drawRect(rect, paint)
The rectangle's left is 50f and right is 200f to match the coordinates.
Fill all three blanks to create a Paint object with stroke style, stroke width 10f, and green color.
val paint = Paint().apply {
style = Paint.Style.[1]
strokeWidth = [2]f
color = Color.[3]
}Stroke style is STROKE, width is 10f, and color is green.
