Recall & Review
beginner
What is a Surface in Android development?
A Surface is a drawing area that holds pixels to be displayed on the screen. It acts like a canvas where you can draw shapes, images, or text.
Click to reveal answer
beginner
How do you create a Shape drawable in Android?
You create a Shape drawable by defining an XML file in the
res/drawable folder using the <shape> tag. You can specify properties like solid color, corners radius, and stroke width.Click to reveal answer
intermediate
What is the difference between
Canvas and SurfaceView?Canvas is an object used to draw on a bitmap or surface. SurfaceView provides a dedicated drawing surface embedded inside a view hierarchy, allowing drawing on a separate thread for better performance.Click to reveal answer
beginner
Why use
ShapeDrawable instead of bitmap images for shapes?ShapeDrawable is scalable and lightweight. It uses vector shapes defined in XML, so it looks sharp on all screen sizes and reduces app size compared to bitmap images.Click to reveal answer
beginner
How can you make a rounded rectangle shape in Android XML?
Use the
<shape> tag with shape="rectangle" and add <corners android:radius="10dp" /> inside it to round the corners.Click to reveal answer
Which Android class provides a dedicated drawing surface for custom drawing on a separate thread?
✗ Incorrect
SurfaceView provides a separate drawing surface that can be updated on a different thread for better performance.
What XML tag is used to define a shape drawable in Android?
✗ Incorrect
The tag defines a shape drawable in XML.
Which property in a shape drawable XML controls the corner rounding?
✗ Incorrect
The corners tag controls the radius of the shape's corners.
Why is ShapeDrawable preferred over bitmap images for simple shapes?
✗ Incorrect
ShapeDrawable is vector-based, so it uses less memory and scales without losing quality.
What does the Canvas class in Android do?
✗ Incorrect
Canvas provides drawing methods to render shapes, text, and images.
Explain how SurfaceView and Canvas work together for custom drawing in Android.
Think about how you would draw moving shapes smoothly.
You got /4 concepts.
Describe how to create and use a shape drawable XML to make a button background with rounded corners.
Imagine styling a button with a colored background and smooth edges.
You got /4 concepts.