在 Jetpack Compose 的文本组件中显示新行
Show a new line in a Text component in Jetpack Compose
我想使用 Jetpack Compose 中的可组合文本显示一些文本,并且文本包含换行符“\n”。如下所示:
Text("This is the first line\nThis is the second line")
但是“\n”最终只是文本。
如何让 Text 组件在单独的一行显示新行?
尝试使用 Text("This is the first line\r\nThis is the second line")
。这应该可以解决您的问题。
我刚试过,我可以在预览和真实设备上看到换行。不确定它是关于撰写版本还是只是错误。
我想使用 Jetpack Compose 中的可组合文本显示一些文本,并且文本包含换行符“\n”。如下所示:
Text("This is the first line\nThis is the second line")
但是“\n”最终只是文本。
如何让 Text 组件在单独的一行显示新行?
尝试使用 Text("This is the first line\r\nThis is the second line")
。这应该可以解决您的问题。
我刚试过,我可以在预览和真实设备上看到换行。不确定它是关于撰写版本还是只是错误。