Wil*_*sby 9 xamarin xamarin.forms
我在堆栈布局中有一个标签.它有它的HorizontalTextAlignment设定TextAlignment.Center.它在页面的初始加载时正常工作,并且在选择新值时 - 但是当页面被遗留然后返回时,它将失去对齐.这只是Android上的一个问题,而不是iOS上的问题.我希望下面的图片可以帮助说明我的观点.这是影响Label对齐的唯一代码,除了它只是通过绑定更改它的文本,但我不知道它会如何改变它的对齐方式.有任何想法吗?谢谢.
StackLayout durationLayout = new StackLayout {
Orientation = StackOrientation.Vertical,
WidthRequest = (App.ScreenDpWidth / 3) - (GMStyle.Margin.PageMargin.Left * 2),
VerticalOptions = LayoutOptions.Center,
Margin = new Thickness(0, 5, 0, 0),
HorizontalOptions = LayoutOptions.Start
};
durationLabel = new Label {
Style = (Style)Application.Current.Resources["DurationLabelStyle"],
HorizontalTextAlignment = TextAlignment.Center,
//VerticalTextAlignment = TextAlignment.Center,
};
durationLabel.SetBinding(Label.TextProperty, "DurationDisplay");
durationLayout.Children.Add(timeSpanPicker);
durationLayout.Children.Add(durationLabel);
durationLayout.GestureRecognizers.Add(timeSpanTap);
Run Code Online (Sandbox Code Playgroud)
Ada*_*ley 27
这是Xamarin Forms中的一个错误,我认为它出现在2.3.3或2.3.4中,它在2.3.2中工作正常.我还不知道有任何针对它的错误报告,这是我能找到的最接近的,可能是相关的.
https://bugzilla.xamarin.com/show_bug.cgi?id=49311
作为一种解决方法,您可以使用HorizontalOptions=LayoutOptions.CenterAndExpand而不是HorizontalTextAlignment.
| 归档时间: |
|
| 查看次数: |
4056 次 |
| 最近记录: |