我正在使用Glide库并想了解有关它的更多详细信息,是否会将整个图片加载到内存中,例如如果我有1920x1080图片并将其加载到屏幕尺寸为640x480的手机上调整大小并压缩或加载整个东西?

还有glide的缩略图功能,它是否只是加载图像的图标版本,以便可用于头像?

最佳答案

1)取决于所选diskCacheStrategy Glide保存或原始图像(在您的情况下为1920x1080)或针对每个视图单独处理的图像(例如,使用.override(int width,int height)方法)。 Glide为您做出的唯一优化就是以RGB_565格式存储图像,而不是系统默认的ARGB_8888。

如果您正在寻找减少流量和内存消耗的策略,请在此处通过下载自定义尺寸的图片来描述模型:

backend requirements

android client implementation

2)缩略图功能-这只是一种选择,可以在容器视图中填充原始图像的缩小副本,以防止在下载最终图像时显示空容器或“进度视图”。这是Java文档缩略图(f浮动)中对它的规则的描述:

* Loads a resource in an identical manner to this request except with the dimensions of the target multiplied
* by the given size multiplier. If the thumbnail load completes before the fullsize load, the thumbnail will
* be shown. If the thumbnail load completes afer the fullsize load, the thumbnail will not be shown.


因此,这不是头像样式的正确选择。通常的方法是覆盖和centerCrop选项的组合。

关于android - 关于Glide库的详细信息,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/32948679/

10-09 16:23
查看更多