https://kotlinlang.org logo
#compose
Title
# compose
k

kyleg

02/18/2020, 8:54 PM
Trying to learn Compose. I see lots of samples people have written using
…, style=+textThemeStyle
but cannot for the life of me figure out what
textThemeStyle
is. There’s a Github project I found that suggests it’s in
androidx.ui.material
but I don’t see it there for me. Probably something that was removed/deprecated-and-removed. What is it replaced by? I have one of my
Composable
functions wrapping a
Scaffold
with
CustomTheme
, and inside there I want to style a
Text
with a
Typography
defined inside the
CustomTheme
.
Nothing I can find in Compose docs when searching on “textThemeStyle”
l

Louis Pullen-Freilich [G]

02/18/2020, 8:55 PM
Yeah that was removed a long time ago, if you're on a newer version of Compose you will want:
MaterialTheme.typography().h1
, replacing
h1
with the style you want
https://developer.android.com/reference/kotlin/androidx/ui/material/MaterialTheme Here's the documentation for the
MaterialTheme
object which is the entry point for accessing the theme
k

kyleg

02/18/2020, 8:57 PM
Cool, thanks. Preview definitely changed, but changed to look like there’s no theme at all now, haha. I’ll investigate, but at least I know how to translate that erstwhile inline function.
r

Ryan Mentley

02/18/2020, 9:09 PM
You'll also want to remove the
+
on newer Compose versions
k

kyleg

02/18/2020, 10:54 PM
Yes, thanks Ryan. The
textThemeStyle
appears to have been removed without notes as to how to replace, but the
unaryPlus
operating on various things in Compose remains in the code but with a
Deprecate
annotation and a note about how it’s not necessary anymore.
2 Views