'using textAppearance in Jetpack compose
Can I still use the TextAppearance stuff in Jetpack compose without much calisthenics? Example textAppearanceHeadline1. How do I do that? I am trying to create a Text view and make it title. But I don't want to specify an actual dp value. So I was hoping to use the usual textAppearanceHeadline1 or such.
Solution 1:[1]
I think this can help you
@OptIn(ExperimentalUnitApi::class)
val textAppearanceHeadline1 = Typography(
h1 = TextStyle(
fontFamily = FontFamily.SansSerif,
fontWeight = FontWeight.Light,
fontStyle = FontStyle.Normal,
fontSize = TextUnit(96f, TextUnitType.Sp),
lineHeight = TextUnit(-0.015625f, TextUnitType.Unspecified),
)
)
And in your Text
Text(text = "Text", style = textAppearanceHeadline1.h1)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 |
