【问题标题】:Grid not expanding to fill screen网格未扩展到填满屏幕
【发布时间】: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
  • Horizo​​ntalOptions = LayoutOptions.FillAndExpand 工作,谢谢!
  • 很高兴它起作用了,我也将其发布为答案

标签: android xamarin android-gridview xamarin.forms


【解决方案1】:

尝试将VerticalOptions = LayoutOptions.FillAndExpand 添加到父StackLayout

【讨论】:

    【解决方案2】:

    就我而言,我必须将 VerticalOptions = FillAndExpand 添加到父 StackLayout 并将祖父 Frame 设置为 Padding = 0

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-11-02
      • 1970-01-01
      • 2015-09-20
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多