Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Apply multiple styles to a single Text - Jetpack Compose

I want to know if there is a way to apply multiple styles to a text, here I apply a material theme to this text, but I also want to change this text size, how can I do it ? since I have already used the style attribute

    Text(text = "This is my default text", style = (MaterialTheme.typography).body1)

Also, how to add 2 modifiers , lets say I want to add padding and also a fillMaxWidth

like image 212
SNM Avatar asked Dec 18 '22 12:12

SNM


1 Answers

For the TestStyle you can use the merge method.
Also if you want to use multiple modifiers you can concatenated them. In this case the order affects the final result.

Example:

Text(
    text = "This is my default text",
    style = (MaterialTheme.typography).body1
        .merge(TextStyle(fontSize = 20.sp)),
    modifier = Modifier
        .padding(start = 16.dp)
        .fillMaxWidth()
)
like image 146
Gabriele Mariotti Avatar answered Dec 21 '22 10:12

Gabriele Mariotti