android - 关于 Glide 库的详细信息

标签 android image resize compression android-glide

我正在使用 Glide图书馆,想知道更多关于它的细节。它是否将整个图片加载到内存中,例如,如果我有一张 1920x1080 图片并将其加载到屏幕尺寸为 640x480 的手机上,它是否会调整大小并压缩或加载整个图片东西?

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

最佳答案

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

如果您正在寻找减少流量和内存消耗的策略,这里是关于下载自定义尺寸图像的模型的描述:

backend requirements

android client implementation

2) 缩略图功能 - 它只是一个选项,可以在下载最终图像时使用原始图像的缩小副本填充容器 View ,而不是显示空容器或“进度 View ”。这是 Java doc thumbnail(float 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.

所以它不是头像样式的合适 vay。通常的方法是结合使用 override 和 centerCrop 选项。

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

相关文章:

android - android :versionName have to be numeric (of the form 0. 0.0 等)?

android - 如何将 Android SpeechRecognizer 作为服务使用?

android - LayoutInflater 属性

php - php 获取混合颜色的百分比

javascript - 如何在 Backbone View 中获取调整大小事件?

css - 关于调整 HTML 元素大小的问题

html - Bootstrap 响应不起作用。

android - 从 Air 打开 'new window' 中的另一个 Android 应用程序

Javascript: move 以编程方式创建的图像不起作用

java - 凸起效应算法说明