作为谷歌推荐的图片加载库,Glide使用起来非常的简单。
1、在项目中添加依赖:
dependencies {
compile 'com.github.bumptech.glide:glide:3.7.0'
}
2、在代码中使用

3、加载图片后效果图:

发现图片并不是我想要的 填充满整个控件的样式。最后在网上找到了答案,顺便在学习了下ImageView。
我的布局文件:

添加 scaleType 属性 为 fitXY后的效果图:

4、Glide 缓存
//跳过内存缓存
Glide.with( context ).load(imageUrl).skipMemoryCache(true).into(imageViewInternet );
//跳过硬盘缓存
Glide.with( context ).load(imageUrl).diskCacheStrategy(DiskCacheStrategy.NONE).into( imageView );
DiskCacheStrategy.NONE 什么都不缓存
DiskCacheStrategy.SOURCE 仅仅只缓存原来的全分辨率的图像
DiskCacheStrategy.RESULT 仅仅缓存最终的图像,即降低分辨率后的(或者是转换后的)
DiskCacheStrategy.ALL 缓存所有版本的图像(**默认行为**)
最后:
scaleType=“matrix” 是保持原图大小、从左上角的点开始,以矩阵形式绘图。
scaleType=“fitXY” 是将原图进行横方向(即XY方向)的拉伸后绘制的。
scaleType=“fitStart” 是将原图沿左上角的点(即matrix方式绘图开始的点),按比例缩放原图绘制而成的。
scaleType=“fitCenter” 是将原图沿上方居中的点(即matrix方式绘图第一行的居中的点),按比例缩放原图绘制而成的。
scaleType=“fitEnd” 是将原图沿下方居中的点(即matrix方式绘图最后一行的居中的点),按比例缩放原图绘制而成的。
scaleType=“Center” 是保持原图大小,以原图的几何中心点和ImagView的几何中心点为基准,只绘制ImagView大小的图像。
scaleType=“centerCrop” 不保持原图大小,以原图的几何中心点和ImagView的几何中心点为基准,只绘制ImagView大小的图像(以填满ImagView为目标,对原图进行裁剪)。
scaleType=“centerInside” 不保持原图大小,以原图的几何中心点和ImagView的几何中心点为基准,只绘制ImagView大小的图像(以显示完整图片为目标,对原图进行缩放)。
scaleType转至http://blog.csdn.net/wa991830558/article/details/39522623
网友评论