0
0
Android Kotlinmobile~5 mins

Surface and shape in Android Kotlin - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
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?
AViewGroup
BCanvas
CSurfaceView
DDrawable
What XML tag is used to define a shape drawable in Android?
A<bitmap>
B<shape>
C<vector>
D<drawable>
Which property in a shape drawable XML controls the corner rounding?
Acorners
Bstroke
Cpadding
Dgradient
Why is ShapeDrawable preferred over bitmap images for simple shapes?
AIt can only be used in SurfaceView
BIt supports animations by default
CIt loads faster from the internet
DIt uses less memory and scales well
What does the Canvas class in Android do?
AProvides methods to draw shapes and text
BHandles user input events
CManages app navigation
DStores app data
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.