Bird
Raised Fist0
Android Kotlinmobile~20 mins

Material Theme customization in Android Kotlin - Practice Problems & Coding Challenges

Choose your learning style10 modes available
Challenge - 5 Problems
🎖️
Material Theme Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ ui_behavior
intermediate
2:00remaining
How does changing the primary color affect the app UI?
You customize the Material Theme by changing the primary color in your theme XML. What visible effect will this have on your app's UI?
AOnly the background color of the app changes, other elements remain the same.
BThe app icon changes color to match the primary color.
CThe color of the app bar and interactive elements like buttons will change to the new primary color.
DThe text color in all TextViews changes to the primary color automatically.
Attempts:
2 left
💡 Hint
Think about which UI parts use the primary color by default in Material Design.
📝 Syntax
intermediate
2:00remaining
Which XML snippet correctly sets a custom secondary color in Material Theme?
You want to set a custom secondary color in your theme XML file. Which snippet is correct?
Android Kotlin
<style name="Theme.MyApp" parent="Theme.Material3.DayNight.NoActionBar">
    <!-- Your code here -->
</style>
A<item name="colorSecondary">#FF5722</item>
B<item name="colorSecondaryVariant">#FF5722</item>
C<item name="secondaryColor">#FF5722</item>
D<item name="colorSecondaryContainer">#FF5722</item>
Attempts:
2 left
💡 Hint
In Material 3, the secondary color attribute is colorSecondary.
❓ lifecycle
advanced
2:00remaining
When should you apply Material Theme customizations in your Android app lifecycle?
At what point in your Android app lifecycle should you apply Material Theme customizations to ensure they affect all UI components?
AIn the Application class's onCreate() method only.
BAfter setContentView() in the Activity's onCreate() method.
CInside the onResume() method of the Activity.
DBefore setContentView() in the Activity's onCreate() method.
Attempts:
2 left
💡 Hint
Think about when the UI is inflated and how themes affect it.
🧠 Conceptual
advanced
2:00remaining
What is the role of color roles like primary, secondary, and tertiary in Material Theme?
Why does Material Theme define color roles such as primary, secondary, and tertiary instead of just using fixed colors everywhere?
ATo provide a consistent color system that adapts to light/dark modes and accessibility needs.
BTo allow developers to use any random colors without restrictions.
CTo force all apps to use the same colors regardless of branding.
DTo reduce the number of colors used in the app to only three.
Attempts:
2 left
💡 Hint
Think about why design systems use roles instead of fixed colors.
🔧 Debug
expert
2:00remaining
Why does your custom Material Theme color not apply to the app bar?
You set a custom primary color in your theme XML, but the app bar still shows the default color. What is the most likely cause?
Android Kotlin
<style name="Theme.MyApp" parent="Theme.Material3.DayNight.NoActionBar">
    <item name="colorPrimary">#6200EE</item>
</style>
AThe colorPrimary attribute is misspelled and ignored by the system.
BYou are using a NoActionBar theme but still have an app bar, so the colorPrimary is ignored.
CYou need to set colorPrimaryVariant instead of colorPrimary for the app bar.
DThe app bar color is controlled by colorSecondary, not colorPrimary.
Attempts:
2 left
💡 Hint
Check if your theme supports the app bar you are using.

Practice

(1/5)
1. What is the main purpose of customizing the MaterialTheme in an Android app?
easy
A. To add new activities to the app
B. To change the app's colors, fonts, and shapes globally
C. To manage app permissions
D. To handle network requests

Solution

  1. Step 1: Understand MaterialTheme role

    The MaterialTheme controls the look and feel of the app by setting colors, typography, and shapes.
  2. Step 2: Identify customization purpose

    Customizing MaterialTheme changes these visual styles globally for consistency.
  3. Final Answer:

    To change the app's colors, fonts, and shapes globally -> Option B
  4. Quick Check:

    MaterialTheme customization = change colors, fonts, shapes [OK]
Hint: MaterialTheme controls app-wide style settings [OK]
Common Mistakes:
  • Confusing theme customization with adding app features
  • Thinking it manages app permissions
  • Assuming it handles network or data logic
2. Which of the following is the correct way to apply a custom color scheme in MaterialTheme in Kotlin?
easy
A. MaterialTheme(colorScheme = myColors) { /* UI content */ }
B. MaterialTheme(colors = myColors) { /* UI content */ }
C. MaterialTheme(setColors = myColors) { /* UI content */ }
D. MaterialTheme(applyColors = myColors) { /* UI content */ }

Solution

  1. Step 1: Recall MaterialTheme parameters

    The correct parameter for colors in MaterialTheme is colorScheme.
  2. Step 2: Match correct syntax

    MaterialTheme(colorScheme = myColors) { /* UI content */ } uses colorScheme = myColors, which is the correct syntax in Kotlin.
  3. Final Answer:

    MaterialTheme(colorScheme = myColors) { /* UI content */ } -> Option A
  4. Quick Check:

    Use colorScheme parameter for colors [OK]
Hint: Use colorScheme, not colors, in MaterialTheme [OK]
Common Mistakes:
  • Using 'colors' instead of 'colorScheme'
  • Using non-existent parameters like 'setColors' or 'applyColors'
  • Forgetting to wrap UI content inside the theme block
3. Given the code snippet below, what color will the Text component display if primary in colorScheme is set to Color.Red?
MaterialTheme(
  colorScheme = ColorScheme(
    primary = Color.Red,
    secondary = Color.Blue
  )
) {
  Text("Hello", color = MaterialTheme.colorScheme.primary)
}
medium
A. Blue
B. Green
C. Red
D. Default text color

Solution

  1. Step 1: Identify colorScheme primary value

    The primary color in colorScheme is set to Color.Red.
  2. Step 2: Check Text color usage

    The Text color uses MaterialTheme.colorScheme.primary, so it will be Color.Red.
  3. Final Answer:

    Red -> Option C
  4. Quick Check:

    Text color = primary color = Red [OK]
Hint: Text color uses primary from colorScheme [OK]
Common Mistakes:
  • Confusing primary with secondary color
  • Assuming default color instead of theme color
  • Mixing up color names
4. What is wrong with the following Kotlin code that tries to customize the MaterialTheme's typography?
MaterialTheme(
  typography = Typography(
    bodyLarge = TextStyle(fontSize = 20)
  )
) {
  Text("Welcome")
}
medium
A. TextStyle requires a unit for fontSize, like sp or dp
B. Typography cannot be customized in MaterialTheme
C. Text component must specify typography explicitly
D. MaterialTheme must not have a typography parameter

Solution

  1. Step 1: Check TextStyle fontSize usage

    The fontSize must include a unit like 20.sp, not just 20.
  2. Step 2: Identify correct syntax

    Without the unit, the code will cause a type error because fontSize expects a TextUnit.
  3. Final Answer:

    TextStyle requires a unit for fontSize, like sp or dp -> Option A
  4. Quick Check:

    fontSize needs unit like sp [OK]
Hint: Always add .sp for fontSize values [OK]
Common Mistakes:
  • Omitting units for fontSize
  • Thinking typography can't be customized
  • Expecting Text to need explicit typography parameter
5. You want to create a custom shape for buttons in your app using MaterialTheme. Which approach correctly applies a rounded corner shape of 16.dp to all buttons?
hard
A. MaterialTheme(shapes = Shapes(extraLarge = RoundedCornerShape(16.dp))) { Button(...) }
B. MaterialTheme(shapes = Shapes(small = RoundedCornerShape(16.dp))) { Button(...) }
C. MaterialTheme(shapes = Shapes(large = RoundedCornerShape(16.dp))) { Button(...) }
D. MaterialTheme(shapes = Shapes(medium = RoundedCornerShape(16.dp))) { Button(...) }

Solution

  1. Step 1: Understand shape categories in MaterialTheme

    MaterialTheme defines shapes as small, medium, and large. Buttons use the medium shape by default.
  2. Step 2: Apply rounded corners to medium shape

    Setting medium = RoundedCornerShape(16.dp) customizes button corners.
  3. Final Answer:

    MaterialTheme(shapes = Shapes(medium = RoundedCornerShape(16.dp))) { Button(...) } -> Option D
  4. Quick Check:

    Buttons use medium shape slot [OK]
Hint: Buttons use medium shape in MaterialTheme [OK]
Common Mistakes:
  • Changing small or large shapes instead of medium
  • Using non-existent shape categories like extraLarge
  • Forgetting to wrap Button inside MaterialTheme
Recommended

Ready to prove it?

Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

10 questions~5 mineasy hard