0
我有3个标签 - 我想居中第二个标签并填充第一个和第三个标签的大小相同的其他空间。Xamarin.Forms没有在android中集中布局
相反,我看到有使用LayoutOption.FillANdExpand
这里当字符串的代价是我的代码:
class MainPage : ContentPage
{
public MainPage()
{
StackLayout a = new StackLayout();
a.Orientation = StackOrientation.Horizontal;
a.Spacing = 0;
a.Padding = new Thickness(0, 0, 0, 0);
a.HorizontalOptions = LayoutOptions.FillAndExpand;
Label l1 = new Label { Text = "1111", HorizontalOptions = LayoutOptions.FillAndExpand, HorizontalTextAlignment = TextAlignment.Center, BackgroundColor = Color.Red, };
Label l2 = new Label { Text = "2222222222222", HorizontalOptions = LayoutOptions.Center, HorizontalTextAlignment = TextAlignment.Center, BackgroundColor = Color.Gray };
Label l3 = new Label { Text = "333333333333", HorizontalOptions = LayoutOptions.FillAndExpand, HorizontalTextAlignment = TextAlignment.Center, BackgroundColor = Color.Red };
a.Children.Add(l1);
a.Children.Add(l2);
a.Children.Add(l3);
Content = a;
}
}
我想111和33333 ...标签具有相同的尺寸并且2222标签位于我的页面中心...