【发布时间】:2015-07-22 13:25:11
【问题描述】:
我有以下网格,它加载在 StackLayout 中:
Grid grid = new Grid {
VerticalOptions = LayoutOptions.FillAndExpand,
HorizontalOptions = LayoutOptions.FillAndExpand,
RowDefinitions =
{
new RowDefinition { Height = new GridLength(40, GridUnitType.Auto) },
new RowDefinition { Height = GridLength.Auto },
new RowDefinition { Height = GridLength.Auto },
new RowDefinition { Height = GridLength.Auto },
new RowDefinition { Height = GridLength.Auto },
new RowDefinition { Height = GridLength.Auto },
new RowDefinition { Height = GridLength.Auto },
new RowDefinition { Height = new GridLength(40, GridUnitType.Auto) },
},
ColumnDefinitions =
{
new ColumnDefinition { Width = new GridLength(100, GridUnitType.Auto) },
new ColumnDefinition { Width = new GridLength(100, GridUnitType.Star) },
new ColumnDefinition { Width = new GridLength(50, GridUnitType.Star) },
new ColumnDefinition { Width = new GridLength(50, GridUnitType.Star) },
new ColumnDefinition { Width = new GridLength(100, GridUnitType.Auto) },
}
};
grid.Children.Add (btnMenu, 0, 1, 0, 1);
grid.Children.Add (lblProfile, 1, 5, 0, 1);
grid.Children.Add (btnEdit, 4, 5, 0, 1);
grid.Children.Add (lblFirstName, 1, 2, 1, 2);
grid.Children.Add (lblFirstNameValue, 2, 3, 1, 2);
Content = new StackLayout {
HorizontalOptions = LayoutOptions.StartAndExpand,
Children = {
grid
}
};
我已经更改了网格宽度的宽度值和类型,但我不能让它填满整个屏幕,除非我使用固定值,这在我的手机上看起来不错,但在其他所有东西上都很糟糕.
【问题讨论】:
-
尝试将
VerticalOptions = LayoutOptions.FillAndExpand添加到父StackLayout -
HorizontalOptions = LayoutOptions.FillAndExpand 工作,谢谢!
-
很高兴它起作用了,我也将其发布为答案
标签: android xamarin android-gridview xamarin.forms