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

Images in Grid adding space above and below (Solved)

$
0
0

Edit: Nevermind. I attached a method to the SizeChanged of the image and set the height equal to the width inside.

Apparently I can't post images, so I'm not sure how to show you the issue. I was under the assumption that using "Auto" for the row height would wrap to the image height. Unfortunately, it adds blank space above and below the image, inside the image view. I can't use an absolute value for the height. Why is it doing this? I've been trying to figure this out for hours. Any insight?

<ContentPage>

    <ContentPage.Content>

        <StackLayout
            HorizontalOptions="FillAndExpand">
            <Grid
                BackgroundColor="blue"
                Margin="5" RowSpacing="5" ColumnSpacing="5">

                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto" />
                </Grid.RowDefinitions>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="*" />
                    <ColumnDefinition Width="*" />
                </Grid.ColumnDefinitions>

                <Image
                    BackgroundColor="Green"
                    x:Name="nutritionButton"
                    Grid.Row="0" Grid.Column="0" />

                <Image
                    BackgroundColor="Green"
                    x:Name="basicButton"
                    Grid.Row="0" Grid.Column="1" />

            </Grid>
        </StackLayout>

    </ContentPage.Content>
</ContentPage>

Viewing all articles
Browse latest Browse all 77050

Trending Articles



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