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.
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)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.