我可以在Jetpack Compose中使用TextAppearance的内容吗?例如 textAppearanceHeadline1
。如何实现呢?我想创建一个标题文本视图,但是我不想指定具体的dp值。所以我希望能够使用通常的textAppearanceHeadline1或类似的东西。
我可以在Jetpack Compose中使用TextAppearance的内容吗?例如 textAppearanceHeadline1
。如何实现呢?我想创建一个标题文本视图,但是我不想指定具体的dp值。所以我希望能够使用通常的textAppearanceHeadline1或类似的东西。
我想这可以帮助你。
@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),
)
)
在你的文本中
Text(text = "Text", style = textAppearanceHeadline1.h1)