Robban
Robban

Reputation: 1221

In Xamarin Forms, how can I show a web image in the same way as a image in the resource folder?

I have a Xamarin forms image where I want to show images from the web, kind of like in a facebook style feed. Due to bandwidth concerns, I do not want to serve high resolution images from my web server.

Now if I add a Image with the Source attribute set to my image url, I cannot get the image to display larger than what it is in native resolution (at least on iOS where I am testing now). This means that to display the image at full width on the later iPhones I need to have a image wider than 1000px.

Is there any way I can make the web images behave more like the images loaded from the resource directory, that are scaled up on higher resolution devices?

Not sure how to explain this in a good way, this repo (not mine) addresses the same problem: https://github.com/williamwilling/xamarin-forms-image-size . Probably not a bug in Xamarin forms I would guess, more a behavior.

Note: I only need this to work on iOS and Android.

Upvotes: 0

Views: 622

Answers (1)

Bruno Caceiro
Bruno Caceiro

Reputation: 7179

You really should consider using the library FFimageLoading.

Here is the example from their wiki. And the images behave similar when loading from a Source / URL. It also allows caching, which is extremely useful.

<ffimageloading:CachedImage HorizontalOptions="Center" VerticalOptions="Center"
        WidthRequest="300" HeightRequest="300"
        DownsampleToViewSize="true"
        Source = "http://loremflickr.com/600/600/nature?filename=simple.jpg">
</ffimageloading:CachedImage>

Upvotes: 0

Related Questions