Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

using textAppearance in Jetpack compose

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.

like image 615
Mesye Konpe Avatar asked Sep 18 '26 20:09

Mesye Konpe


1 Answers

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)
like image 56
OneDev Avatar answered Sep 21 '26 11:09

OneDev



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!