ImageService.Instance.LoadFile
:它用于从磁盘加载文件(仅限完整路径)。
您应该使用LoadFileFromApplicationBundle
(应用程序包)或LoadCompiledResource
(应用程序资源)。
从应用程序包中的文件加载图像。
/// <summary>
/// Load an image from a file from application bundle.
/// eg. assets on Android, compiled resource for other platforms
/// </summary>
/// <returns>The new TaskParameter.</returns>
/// <param name="filepath">Path to the file.</param>
TaskParameter LoadFileFromApplicationBundle(string filepath);
Xamarin.Android
xml:
<FFImageLoading.Views.ImageViewAsync
android:id="@+id/imageView"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
资产:使用 AndroidAsset 的 Build Action
主要活动:
var imageView = FindViewById<ImageView>(Resource.Id.imageView);
var filePath = "sample2.svg";
ImageService.Instance.LoadFileFromApplicationBundle(filePath).WithCustomDataResolver(new SvgDataResolver(64, 0, true)).Into(imageView);
从应用程序资源的文件中加载图像。使用可绘制文件夹中的资源名称,不带扩展名。
/// <summary>
/// Load an image from a file from application resource.
/// </summary>
/// <returns>The new TaskParameter.</returns>
/// <param name="resourceName">Name of the resource in drawable folder without extension</param>
TaskParameter LoadCompiledResource(string resourceName);
Xamarin.Android
xml:
<FFImageLoading.Views.ImageViewAsync
android:id="@+id/imageView"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
可绘制资源:与 AndroidResource 的 BuildAction
主要活动:
var filePath = "sample";
ImageService.Instance.LoadCompiledResource(filePath).WithCustomDataResolver(new SvgDataResolver(64, 0, true)).Into(imageView);
在您提供的链接中,它还显示了从 Xamarin.Forms 上的嵌入式资源加载的方式,您可以检查它。https://github.com/luberda-molinet/FFImageLoading/wiki/SVG-support#xamarinandroid