Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 91519

VerticalOptions = LayoutOptions.End inside Autosized Grid Row is leaving gap

$
0
0

I'm having a problem with VerticalOptions = LayoutOptions.End inside a grid row. At first I thought it was an issue with Image and autosized rows, but I tried a BoxView and it is also leaving a small gap between the end of the control and the end of the row. I also tried changing the row from autosized to GridLength(1, GridUnitType.Star) to see if that resolved it and it still leaves the gap. I've set padding, and rowspacing both to 0 on the grid so it's not either of those. Incidentally, if I set the VerticalOptions = LayoutOptions.Fill then the gap disappears. It looks like a bug in the End calculation? My row has two images, one is set to FILL vertically, the other smaller image must appear at the END vertically. The problem manifests on Android (both XHDPI and XXHDPI) but does not appear on iOS.

Anyone have any ideas on how to fix it?

                var grid = new Grid
                {
                    ColumnSpacing = 0,
                    RowSpacing = 0,
                    VerticalOptions = LayoutOptions.Fill,
                    HorizontalOptions = LayoutOptions.Fill,
                    RowDefinitions = {
                        new RowDefinition { Height = GridLength.Auto},
                        new RowDefinition { Height = new GridLength(1, GridUnitType.Star)},
                        new RowDefinition { Height = GridLength.Auto}
                    },
                    ColumnDefinitions = {
                        new ColumnDefinition { Width = GridLength.Auto},
                        new ColumnDefinition { Width = new GridLength(1, GridUnitType.Star)},
                        new ColumnDefinition { Width = GridLength.Auto}
                    }
                };

                var groundImage = new Image
                {
                    Source = "Images/Core/groundicon.png",                //1280 x 180
                    HorizontalOptions = LayoutOptions.Fill,
                    VerticalOptions = LayoutOptions.End
                };

                var treasuryImage = new Image
                {
                    Source = "Images/Core/bankmoneyicon.png",       //256 x 256
                    HorizontalOptions = LayoutOptions.Center,
                    VerticalOptions = LayoutOptions.Fill
                };

                grid.Children.Add(groundImage, 0, 2);
                Grid.SetColumnSpan(groundImage, 3);

                grid.Children.Add(treasuryImage, 1, 2);

Viewing all articles
Browse latest Browse all 91519

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>