Adam
Adam

Reputation: 2137

How to set lineHeight as multiple of default in Jetpack Composable?

I have the following code. As you can see, the lineHeight on the Text composable is being set to a specific SP. I think it would be better however if I could multiply the default lineHeight by a float such as 1.2f so that I know I'm always making the lineHeight more than the default, and by what amount, rather than guessing.

Is this possible to do? I've tried to track down the default lineHeight in the source code but to no avail.

@Composable
fun ListItem(
    ritual: Ritual,
    modifier: Modifier = Modifier
) {
    Box(modifier) {
        Text(
            text = ritual.name,
            modifier = Modifier
                .wrapContentSize()
                .padding(
                    start = 16.dp,
                    end = 8.dp,
                    bottom = 20.dp
                ),
            fontSize = 24.sp,
            lineHeight = 24.sp
        )
    }
}

Upvotes: 0

Views: 133

Answers (0)

Related Questions