Xamarin图片来源

时间:2019-12-17 17:37:21

标签: c# xamarin xamarin.forms

很抱歉,如果以前有人问过这个问题。

我有一个非常简单的问题,我想知道我是否缺少明显的东西。在我的实践Xamarin.Forms应用程序中,即使通过浏览器到达以下图像源URI,也无法加载http://lorempixel.com/1920/1080/sports/7/:没事。

在我看来,Xamarin需要扩展图像才能正常工作,例如,如果我要在线上某种图像,如{https://www.stickpng.com/assets/images/58b061138a4b5bbbc8492951.png,警告,如果该链接可以下载猫图像,您可以查看),然后加载正常。

我的问题有两个:我是否缺少我需要启用的简单配置(这是针对Android的,因为我没有可用的atm的iOS设备),并且B:xamarin甚至支持相对路径吗?

后面的代码:

var source = new UriImageSource 
{ 
    Uri = new Uri("http://lorempixel.com/1920/1080/sports/7/")
};

source.CachingEnabled = false;

ImageOne.Source = source;

1 个答案:

答案 0 :(得分:2)

说明

iOS和Android现在都需要https

答案

应该容易解决-将http更改为https

var source = new UriImageSource 
{ 
    Uri = new Uri("https://lorempixel.com/1920/1080/sports/7/")
};

source.CachingEnabled = false;

ImageOne.Source = source;