繁体   English   中英

在 Jetpack compose 中使用 textAppearance

[英]using textAppearance in Jetpack compose

我仍然可以在没有太多健美操的情况下使用 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)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM