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
Step 1: Check TextStyle fontSize usage
The fontSize must include a unit like 20.sp, not just 20.
Step 2: Identify correct syntax
Without the unit, the code will cause a type error because fontSize expects a TextUnit.
Final Answer:
TextStyle requires a unit for fontSize, like sp or dp -> Option A
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
Step 1: Understand shape categories in MaterialTheme
MaterialTheme defines shapes as small, medium, and large. Buttons use the medium shape by default.
Step 2: Apply rounded corners to medium shape
Setting medium = RoundedCornerShape(16.dp) customizes button corners.