[英]How to set line-space with Android Jetpack Compose Text()?
I want to give more space dp
between lines in the Text()
content.我想在Text()
内容的行之间留出更多的空间dp
。 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?我找到的唯一属性是TextStyle
的letterSpacing
,但是,它似乎不是我想要的,我们可以以某种方式设置它吗?
With 1.0.0
you can use the lineHeight
property:在1.0.0
您可以使用lineHeight
属性:
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
20.sp
和50.sp
or you can use the TextStyle
:或者您可以使用TextStyle
:
Text(text = "Hello Compose".repeat(50),
modifier = Modifier.padding(10.dp).width(200.dp),
maxLines = 5,
style = LocalTextStyle.current.copy(lineHeight = 50.sp)
)
嗨,尝试更改 TextView 的样式属性 - TextStyle.lineHeight
I did it like this.我是这样做的。
Text(text = "Hello",
style = MaterialTheme.typography.h5.copy(
lineHeight = 35.sp, // Here line height
),
)
Or simply you can use lineHeight或者干脆你可以使用 lineHeight
Text(text = "Hello",
lineHeight = 35.sp
)
Caution: sp is case sensitive注意:sp 区分大小写
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.