【发布时间】:2018-12-27 21:21:02
【问题描述】:
我试图在 Label Xamarin Forms 中对齐文本,但不能,
如何在不使用 webview 的情况下像图片一样对齐文本(不只是样式对齐)
我附上了我的代码,但它的理由只剩下了
string strText="MY LONG TEXT IS GOING HERE";
var lblMSG = new Label {TextColor = Color.Black };
lblMSG.Text=strText;
lblMSG.LineBreakMode = LineBreakMode.WordWrap;
lblMSG.HorizontalOptions = LayoutOptions.Fill;
lblMSG.HorizontalTextAlignment = TextAlignment.Start;
lblMSG.VerticalTextAlignment = TextAlignment.Center;
StackLayout stk= new StackLayout { Children = { lblMSG}, BackgroundColor = Color.White ,HorizontalOptions =LayoutOptions.FillAndExpand }
【问题讨论】:
-
您的意思是设置文本样式吗?如果是,则需要手动制作。
-
不只是造型,我使用 FormattedString()
-
"lblMSG.HorizontalTextAlignment = TextAlignment.Start;"使文本从左侧开始。尝试将其更改为 TextAlignment.Center。
标签: c# xamarin xamarin.forms