0
0
Android Kotlinmobile~10 mins

Material Theme customization 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 set the Material theme in the activity.

Android Kotlin
setTheme(R.style.[1])
Drag options to blanks, or click blank then click option'
ATheme_MaterialComponents_DayNight
BTheme_AppCompat
CTheme_Holo
DTheme_DeviceDefault
Attempts:
3 left
💡 Hint
Common Mistakes
Using AppCompat or Holo themes which are not Material Components themes.
Forgetting to set the theme before super.onCreate.
2fill in blank
medium

Complete the code to apply a custom colorPrimary in the Material theme XML.

Android Kotlin
<color name="[1]">#6200EE</color>
Drag options to blanks, or click blank then click option'
AcolorAccent
BcolorPrimary
CcolorBackground
DcolorSurface
Attempts:
3 left
💡 Hint
Common Mistakes
Confusing colorPrimary with colorAccent or other colors.
Using invalid hex color codes.
3fill in blank
hard

Fix the error in the theme XML to correctly inherit from a Material Components theme.

Android Kotlin
<style name="AppTheme" parent="[1]">
    <!-- Customize your theme here. -->
</style>
Drag options to blanks, or click blank then click option'
ATheme.MaterialComponents.Light.DarkActionBar
BTheme.DeviceDefault.Light.DarkActionBar
CTheme.Holo.Light.DarkActionBar
DTheme.AppCompat.Light.DarkActionBar
Attempts:
3 left
💡 Hint
Common Mistakes
Using AppCompat or Holo themes as parent which breaks Material theming.
Misspelling the theme name.
4fill in blank
hard

Fill both blanks to define a custom Material theme color and apply it in colors.xml.

Android Kotlin
<color name="[1]">#03DAC5</color>
<color name="[2]">#018786</color>
Drag options to blanks, or click blank then click option'
AcolorSecondary
BcolorPrimaryVariant
CcolorSecondaryVariant
DcolorPrimary
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing primary and secondary color names.
Using incorrect hex codes for variants.
5fill in blank
hard

Fill all three blanks to create a theme overlay with a custom font family and apply it in styles.xml.

Android Kotlin
<style name="CustomFontTheme" parent="[1]">
    <item name="fontFamily">@font/[2]</item>
    <item name="textAppearanceHeadline1">@style/[3]</item>
</style>
Drag options to blanks, or click blank then click option'
ATheme.MaterialComponents.DayNight.NoActionBar
Bcustom_font
CTextAppearance.MaterialComponents.Headline1
DTheme.AppCompat.Light.NoActionBar
Attempts:
3 left
💡 Hint
Common Mistakes
Using AppCompat theme as parent which lacks Material support.
Incorrect font resource name or missing textAppearance style.