Forum Xamarin.Forms

Xamarin Forms image with aspect ration

I am struggling here... What I want to do seems like it should be so simple but after countless web searches and trial and error I just cannot seem to figure out how to work with images. I am new to app development, just getting started and using Xamarin because it's cross platform, so figured it's a good tool to learn.

Anyhow, I am trying to do something that seems like it should be super simple to do. I want to put a bunch of images on a screen, all of which use the entire width of the screen, while maintaining aspect ratio. The images will load from url, I will always know the initial dimensions height/width.

Xamarin Forms.

 <Grid x:Name="gr" Padding="0">
            <Grid.RowDefinitions>
            <RowDefinition Height="150"/>
            <RowDefinition Height="100"/>
            <RowDefinition />
            <RowDefinition />

            </Grid.RowDefinitions>
            <Image x:Name="im2" Source="https://via.placeholder.com/350x150" Aspect="AspectFill" Grid.Row="0"/>
            <Image x:Name="im3" Source="https://via.placeholder.com/200x100" Aspect="AspectFill" Grid.Row="1" HeightRequest="100" WidthRequest="200"/>
            <Image x:Name="im4" Source="https://via.placeholder.com/140x100" Aspect="AspectFit" Grid.Row="2"/>
            <Image x:Name="im5" Source="https://via.placeholder.com/100x140" Aspect="AspectFill" Grid.Row="3"/>
            <Image x:Name="im6" Source="https://via.placeholder.com/350x150" Aspect="AspectFill" Grid.Row="4"/>
        </Grid>

I just want to place a bunch of images on the screen, in a Grid, which is in a Scrollview. Allow the user to scroll through them.
What is the trick I am missing. I have tried countless trial and error, I know this can't be that hard to do, I am just overlooking something.

No matter what I seem to try, it's either not filling the screen out, or it's cropping off parts of the image.

Tagged:
Sign In or Register to comment.