最佳答案
就像 @Quantic 所说,您可以简单地在文本中添加新行,例如:
Label.Text = "I got it. Take me to the" + Environment.NewLine + "Home Screen";
这与执行相同:
Label.Text = "I got it. Take me to the\nHome Screen";
或者使用StackLayout
:
StackLayout layout = new StackLayout {
Orientation = StackOrientation.Horizontal,
Children = {
new Label { Text = "I got it. Take me to the" },
new Label { Text = "Home Screen" },
}
}
尽管如此,您可能不想这样做,因为不同的屏幕具有不同的宽度,因此您需要考虑到这一点。不同的设备还可以更改应用中的文本大小,这样也会影响大小。
*编辑:如果您希望Label
的尾部截断文本,那么您需要设置Label
的LineBreakMode
像这样:
Label.LineBreakMode = LineBreakMode.TailTruncation
有时这不起作用,具体取决于您的 Label
所包含的布局类型,因此如果它不起作用,请让我知道您存储 的布局类型标签
中。
因此,如果您在 StackLayout
中有 Label
,截断可能无法在 Android 上正常工作。尝试将 Label
放入 Grid
中。请参阅this为遇到此问题的其他人发布帖子。
关于c# - 如何连续制作两个标签?第二个标签正确显示新行?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40138420/