Tomáš Hubálek
12/09/2021, 12:37 PMText(
text = "Something",
style = MaterialTheme.typography.body1
)
then color is wrong when Android is set to dark mode.
It is somehow connected to `Surface`/`Scaffold`but it is still not working for me.
Why it is designed in so counterintuitive way? It looks like I have to specify colors in Typography
(which is solution I feel is wrong as colors should be in ColorScheme IMHO)Jan Bína
12/09/2021, 11:43 PM@Composable fun AppContent() {
val isDarkTheme = isSystemInDarkTheme()
val colors = if (isDarkTheme) darkColors() else lightColors()
MaterialTheme(colors = colors) {
// here, colors from MaterialTheme.colors will respect the system theme
// you can either use them directly:
Text(text = "Text", color = MaterialTheme.colors.onSurface)
// or wrap your text in Surface, Scaffold or other Material widget
// those widgets set LocalContentColor which is the default color for Text widget
Surface { Text(text = "Text") }
}
}