0
0
Android Kotlinmobile~10 mins

Surface and shape in Android Kotlin - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to create a rounded corner shape with 16.dp radius.

Android Kotlin
val shape = RoundedCornerShape([1])
Drag options to blanks, or click blank then click option'
A24.dp
B8.dp
C16.dp
D32.dp
Attempts:
3 left
💡 Hint
Common Mistakes
Using a plain number without dp causes errors.
Using too small or too large values changes the shape unexpectedly.
2fill in blank
medium

Complete the code to set a background color and shape to a Box composable.

Android Kotlin
Box(modifier = Modifier.background(color = Color.Blue, shape = [1]))
Drag options to blanks, or click blank then click option'
ACutCornerShape(4.dp)
BRectangleShape
CRoundedCornerShape(8.dp)
DCircleShape
Attempts:
3 left
💡 Hint
Common Mistakes
Using RectangleShape will not round the corners.
Using RoundedCornerShape requires specifying the radius.
3fill in blank
hard

Fix the error in the code to clip a composable with a rounded shape.

Android Kotlin
Modifier.[1](RoundedCornerShape(12.dp))
Drag options to blanks, or click blank then click option'
Aborder
Bclip
Cpadding
Dbackground
Attempts:
3 left
💡 Hint
Common Mistakes
Using background only sets color but does not clip.
Using padding or border does not clip the shape.
4fill in blank
hard

Fill both blanks to create a Box with a red background and a cut corner shape of 10.dp.

Android Kotlin
Box(modifier = Modifier.background(color = [1], shape = [2]))
Drag options to blanks, or click blank then click option'
AColor.Red
BColor.Green
CCutCornerShape(10.dp)
DRoundedCornerShape(10.dp)
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing rounded and cut corner shapes.
Using wrong color constants.
5fill in blank
hard

Fill all three blanks to create a Surface with a blue color, rounded corners of 20.dp, and elevation of 8.dp.

Android Kotlin
Surface(color = [1], shape = [2], elevation = [3]) {
    // content here
}
Drag options to blanks, or click blank then click option'
AColor.Blue
BRoundedCornerShape(20.dp)
C8.dp
DCutCornerShape(20.dp)
Attempts:
3 left
💡 Hint
Common Mistakes
Using cut corner shape instead of rounded.
Forgetting to add elevation or using wrong units.