如何使用 Android Jetpack Compose Text() 设置行距? [英] How to set line-space with Android Jetpack Compose Text()?
本文介绍了如何使用 Android Jetpack Compose Text() 设置行距?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想在 Text()
内容的行之间留出更多的空间 dp
.我找到的唯一属性是 TextStyle
的 letterSpacing
,但是,它似乎不是我想要的,我们可以以某种方式设置它吗?
解决方案
使用 1.0.0
你可以使用
或者您可以使用TextStyle
:
Text(text = "Hello Compose".repeat(50),修饰符 = Modifier.padding(10.dp).width(200.dp),最大线数 = 5,样式 = LocalTextStyle.current.copy(lineHeight = 50.sp))
I want to give more space dp
between lines in the Text()
content. The only property I find is the letterSpacing
of TextStyle
, however, it doesn't seem as I want, can we set it with composing somehow?
解决方案
With 1.0.0
you can use the lineHeight
property:
Text(text = "Hello Compose".repeat(50),
modifier = Modifier.padding(10.dp).width(200.dp),
maxLines = 5,
lineHeight = 50.sp
)
With 20.sp
and 50.sp
or you can use the TextStyle
:
Text(text = "Hello Compose".repeat(50),
modifier = Modifier.padding(10.dp).width(200.dp),
maxLines = 5,
style = LocalTextStyle.current.copy(lineHeight = 50.sp)
)
这篇关于如何使用 Android Jetpack Compose Text() 设置行距?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文