Here is xaml (an image in stacklayout). Everything is logical: I set Aspect to AspectFit and HorizontalOptions to FillAndExpand. Width of image must fill the width of stacklayout. Height must be calculated in order to image Aspect.
<Image BackgroundColor="Fuchsia" Aspect="AspectFit" Source="{Binding GroupLogo}" HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand"/>
It fill the width but It doesn't want to draw image full width. Why?
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With