我有以下网格,它被加载到 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
关于android - 网格未扩展以填满屏幕,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31564502/