簡體   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