Xamarin Forms Image fill width with proper aspect

AspectFit does what it says on the tin, it will fit the whole image into the View, which may leave parts of the view empty. Straight from Xamarin’s documentation:

Scale the image to fit the view. Some parts may be left empty (letter boxing).

What you’re looking for is AspectFill, which will scale the image to fit:

Scale the image to fill the view. Some parts may be clipped in order to fill the view.

If you are trying to get the image view to be the height of the image, I’d suggest adding a HeightRequest to the height of the image. Image controls don’t seem to automatically scale in Xamarin, in my experience, as the native controls don’t appear to support that by default either.

Reference

Leave a Comment