Xamarin Forms Image fill width with proper aspect

后端 未结 11 2210
我寻月下人不归
我寻月下人不归 2020-12-09 08:05

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 stackl

11条回答
  •  悲哀的现实
    2020-12-09 08:36

    Try using CachedImage from FFImageLoading NuGet package

    MyPage.xaml

    
        
    
    

    This will results image trying to horizontally fill the container and to automatically generate the width while maintaining its aspect.

    Add this line of code to MainActivity.xaml after global::Xamarin.Forms.Forms.Init(this, bundle);

    CachedImageRenderer.Init(true);
    

    Example can be found here

提交回复
热议问题