Component - Material Theme customization
This UI component shows how to customize the Material Theme colors and typography in an Android app using Kotlin. It changes the app's look by applying new colors and font styles globally.
This UI component shows how to customize the Material Theme colors and typography in an Android app using Kotlin. It changes the app's look by applying new colors and font styles globally.
MaterialTheme ├── Scaffold │ ├── TopAppBar │ └── Column │ ├── Text (Title) │ └── Button
MaterialTheme in an Android app?MaterialTheme controls the look and feel of the app by setting colors, typography, and shapes.MaterialTheme changes these visual styles globally for consistency.MaterialTheme in Kotlin?colorScheme.colorScheme = myColors, which is the correct syntax in Kotlin.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)
}primary color in colorScheme is set to Color.Red.Text color uses MaterialTheme.colorScheme.primary, so it will be Color.Red.MaterialTheme(
typography = Typography(
bodyLarge = TextStyle(fontSize = 20)
)
) {
Text("Welcome")
}fontSize must include a unit like 20.sp, not just 20.TextUnit.small, medium, and large. Buttons use the medium shape by default.medium = RoundedCornerShape(16.dp) customizes button corners.Pass the test and this pattern moves unknown