Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to display a simple text "Hello World" using Text composable.
Android Kotlin
Text(text = [1]) Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Forgetting quotes around the string
Passing the whole Text() call inside the text parameter
✗ Incorrect
The Text composable requires a string passed to the text parameter. Use quotes to define the string.
2fill in blank
mediumComplete the code to set the font size of the Text composable to 24.sp.
Android Kotlin
Text(text = "Welcome", fontSize = [1])
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Passing fontSize as a plain number without .sp
Passing fontSize as a string
✗ Incorrect
In Jetpack Compose, fontSize expects a TextUnit, so use 24.sp to specify 24 scale-independent pixels.
3fill in blank
hardFix the error in the code to correctly display bold text using Text composable.
Android Kotlin
Text(text = "Bold Text", fontWeight = [1])
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using lowercase 'bold' instead of FontWeight.Bold
Passing a string instead of FontWeight.Bold
✗ Incorrect
FontWeight.Bold is the correct enum value to make text bold in Compose. It is case sensitive.
4fill in blank
hardFill both blanks to create a Text composable with italic style and blue color.
Android Kotlin
Text(text = "Styled Text", fontStyle = [1], color = [2])
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using FontStyle.Bold instead of FontStyle.Italic
Using Color.Red instead of Color.Blue
✗ Incorrect
FontStyle.Italic makes the text italic. Color.Blue sets the text color to blue.
5fill in blank
hardFill all three blanks to create a Text composable with underlined decoration, font size 18.sp, and green color.
Android Kotlin
Text(text = "Decorated", textDecoration = [1], fontSize = [2], color = [3])
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using TextDecoration.LineThrough instead of Underline
Forgetting .sp on font size
Using wrong color constant
✗ Incorrect
TextDecoration.Underline adds underline. 18.sp sets font size. Color.Green colors the text green.