Xamarin.android 在FFImageLoading中,如何在Xamarin Android中将图像加载到内存中?
这样做,我相信我的图像只缓存在磁盘上:Xamarin.android 在FFImageLoading中,如何在Xamarin Android中将图像加载到内存中?,xamarin.android,ffimageloading,Xamarin.android,Ffimageloading,这样做,我相信我的图像只缓存在磁盘上: ImageService.Instance.LoadUrl(item.profileImg) .DownSample() .BitmapOptimizations(true) .LoadingPlaceholder("blank_profile_img.png", FFImageLoading.Work.ImageSource.CompiledResource) .Into(holder.imgIcon); 据我所知,您可以简单地指定要用于该特定图像的缓
ImageService.Instance.LoadUrl(item.profileImg)
.DownSample()
.BitmapOptimizations(true)
.LoadingPlaceholder("blank_profile_img.png", FFImageLoading.Work.ImageSource.CompiledResource)
.Into(holder.imgIcon);
据我所知,您可以简单地指定要用于该特定图像的缓存类型,因为它是根据密钥存储的 因此,我使用这个库的一个例子如下:
ImageService.Instance.LoadUrl(url)
.WithPriority(LoadingPriority.High)
.Retry(3, 200)
.LoadingPlaceholder("ProfilePlaceholder.png", ImageSource.CompiledResource)
.ErrorPlaceholder("ProfilePlaceholder.png", ImageSource.CompiledResource)
.WithCache(FFImageLoading.Cache.CacheType.All)
.Into(profileImage);
ImageService.Instance.LoadUrl(item.profileImg)
.DownSample()
.BitmapOptimizations(true)
.LoadingPlaceholder("blank_profile_img.png", FFImageLoading.Work.ImageSource.CompiledResource)
.WithCache(FFImageLoading.Cache.CacheType.Memory)
.Into(holder.imgIcon);
关键部分是:
.WithCache(FFImageLoading.Cache.CacheType.All)
您可以指定All
,这意味着它将缓存到IO
和memory
,或者您可以选择它只是IO
,或者只是memory
所以你的看起来像:
ImageService.Instance.LoadUrl(url)
.WithPriority(LoadingPriority.High)
.Retry(3, 200)
.LoadingPlaceholder("ProfilePlaceholder.png", ImageSource.CompiledResource)
.ErrorPlaceholder("ProfilePlaceholder.png", ImageSource.CompiledResource)
.WithCache(FFImageLoading.Cache.CacheType.All)
.Into(profileImage);
ImageService.Instance.LoadUrl(item.profileImg)
.DownSample()
.BitmapOptimizations(true)
.LoadingPlaceholder("blank_profile_img.png", FFImageLoading.Work.ImageSource.CompiledResource)
.WithCache(FFImageLoading.Cache.CacheType.Memory)
.Into(holder.imgIcon);
我最终使用了Glide,但它的性能更好