简体   繁体   English

在 Jetpack compose 中使用 textAppearance

[英]using textAppearance in Jetpack compose

Can I still use the TextAppearance stuff in Jetpack compose without much calisthenics?我仍然可以在没有太多健美操的情况下使用 Jetpack compose 中的 TextAppearance 东西吗? Example textAppearanceHeadline1 .示例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.但我不想指定实际的 dp 值。 So I was hoping to use the usual textAppearanceHeadline1 or such.所以我希望使用通常的 textAppearanceHeadline1 等。

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)

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

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