[英]Show a new line in a Text component in Jetpack Compose
I want to display some text using the Text composable in Jetpack Compose and the text contains a new line character ' \n '.我想使用 Jetpack Compose 中的可组合文本显示一些文本,并且文本包含换行符“ \n ”。 Something like below:如下所示:
Text("This is the first line\nThis is the second line")
But the ' \n ' ends up just being text.但 ' \n ' 最终只是文本。
How can I get the Text component to display the new line on a separate line?如何让 Text 组件在单独的行上显示新行?
Try using Text("This is the first line\r\nThis is the second line")
.尝试使用Text("This is the first line\r\nThis is the second line")
。 This should solve your problem.这应该可以解决您的问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.