http://blog.csdn.net/vipzjyno1/article/details/23206387

在gradle添加:

compile 'com.nostra13.universalimageloader:universal-image-loader:1.9.5'

创建类继承Application定义全局的imageLoader

public class MyApplication extends Application {
@Override
public void onCreate() {
/**
* 全局的ImageLoader
* */ DisplayImageOptions defaultOptions = new DisplayImageOptions.Builder()
.showImageOnLoading(R.mipmap.image_group_load_f) //设置图片在下载期间显示的图片
.showImageForEmptyUri(R.mipmap.image_group_load_f)//设置图片Uri为空或是错误的时候显示的图片
.showImageOnFail(R.mipmap.image_group_load_f) //设置图片加载/解码过程中错误时候显示的图片
.cacheInMemory(true)//设置下载的图片是否缓存在内存中
.cacheOnDisc(true)//设置下载的图片是否缓存在SD卡中
.considerExifParams(true) //是否考虑JPEG图像EXIF参数(旋转,翻转)
.imageScaleType(ImageScaleType.EXACTLY_STRETCHED)//设置图片以如何的编码方式显示
.bitmapConfig(Bitmap.Config.RGB_565)//设置图片的解码类型//
// .decodingOptions(android.graphics.BitmapFactory.Options decodingOptions)//设置图片的解码配置
//.delayBeforeLoading(int delayInMillis)//int delayInMillis为你设置的下载前的延迟时间
//设置图片加入缓存前,对bitmap进行设置
//.preProcessor(BitmapProcessor preProcessor)
.resetViewBeforeLoading(true)//设置图片在下载前是否重置,复位
.displayer(new RoundedBitmapDisplayer(20))//是否设置为圆角,弧度为多少
.displayer(new FadeInBitmapDisplayer(100))//是否图片加载好后渐入的动画时间
.build();//构建完成 ImageLoaderConfiguration config = new ImageLoaderConfiguration
.Builder(getApplicationContext())
.memoryCacheExtraOptions(480, 800) // max width, max height,即保存的每个缓存文件的最大长宽
// .discCacheExtraOptions(480, 800, Bitmap.CompressFormat.JPEG, 75, null) //设置缓存的详细信息,最好不要设置这个
.threadPoolSize(3)//线程池内加载的数量
.threadPriority(Thread.NORM_PRIORITY - 2)
.denyCacheImageMultipleSizesInMemory()
.memoryCache(new UsingFreqLimitedMemoryCache(2 * 1024 * 1024)) // 你可以通过自己的内存缓存实现
.memoryCacheSize(2 * 1024 * 1024)
.discCacheSize(50 * 1024 * 1024)
.discCacheFileNameGenerator(new Md5FileNameGenerator())//将保存的时候的URI名称用MD5 加密
.tasksProcessingOrder(QueueProcessingType.LIFO)
.discCacheFileCount(100) //缓存的文件数量
// .discCache(new UnlimitedDiscCache(cacheDir))//自定义缓存路径
.defaultDisplayImageOptions(DisplayImageOptions.createSimple())
.imageDownloader(new BaseImageDownloader(getApplicationContext(), 5 * 1000, 30 * 1000)) // connectTimeout (5 s), readTimeout (30 s)超时时间
.writeDebugLogs() // Remove for release app
.build();//开始构建
ImageLoader.getInstance().init(config);
super.onCreate(); }
}
在Mainfest中指定application 以及访问网络权限

<uses-permission android:name="android.permission.INTERNET" />
android:name=".application.MyApplication"

在需要使用的时候
private ImageLoader loader = ImageLoader.getInstance();
loader.loadImage(url, new ImageLoadingListener()

ImageLoder配置以及使用(个人阅读使用)的更多相关文章

  1. IntelliJ IDEA 配置 Hadoop 源码阅读环境

    1.下载安装IDEA https://www.jetbrains.com/idea/download/#section=windows 2.下载hadoop源码 https://archive.apa ...

  2. Jexus-5.6.3使用详解、Jexus Web Server配置

    一.Jexus Web Server配置   在 jexus 的工作文件夹中(一般是“/usr/jexus”)有一个基本的配置文件,文件名是“jws.conf”. jws.conf 中至少有 Site ...

  3. Anaconda多环境多版本python配置指导

    Anaconda多环境多版本python配置指导 字数3696 阅读644 评论0 喜欢0 最近学python,读完了语法后在GitHub找了一些练习来做,由 于学的是python3.x语法,而Git ...

  4. Spring Boot 探索系列 - 自动化配置篇

    26. Logging Prev  Part IV. Spring Boot features  Next 26. Logging Spring Boot uses Commons Logging f ...

  5. 网站环境apache + php + mysql 的XAMPP,如何实现一个服务器上配置多个网站?

    xampp 是一个非常方便的本地 apache + php + mysql 的调试环境,在本地安装测试 WordPress 等各种博客.论坛程序非常方便.今天我们来给大家介绍一下,如何使用 XAMPP ...

  6. 近日测试发现所有Excel相关功能均会抛异常,查后发现与福昕阅读器不兼容

    报这种错: System.Runtime.InteropServices.COMException (0x80010105): 服务器出现意外情况. (异常来自 HRESULT:0x80010105 ...

  7. [Kubernetes]安装和配置kubectl

    安装kubectl 安装kubectl比较简单,几条命令即可(#后面为注释内容): #下载最新版本: curl -LO https://storage.googleapis.com/kubernete ...

  8. spring cloud 使用spring cloud bus自动刷新配置

    Spring Cloud Bus提供了批量刷新配置的机制,它使用轻量级的消息代理(例如RabbitMQ.Kafka等)连接分布式系统的节点,这样就可以通过Spring Cloud Bus广播配置的变化 ...

  9. Spring Boot SSL [https]配置例子

    前言 本文主要介绍Spring Boot HTTPS相关配置,基于自签证书实现: 通过本例子,同样可以了解创建SSL数字证书的过程: 本文概述 Spring boot HTTPS 配置 server. ...

随机推荐

  1. git代码提交方式

    https://my.oschina.net/tearlight/blog/193921 <a>github的提交方式      (1)git add .----------------- ...

  2. Windows Server 2012 (2008) 忘记密码重置方法 Windows 10 忘记密码

    要使用windows server 2012安装DVD,选择光盘引导进入 进入修复系统---命令提示符---切换目录至系统目录--执行move命令    先备份  utilman.exe(他就是这个程 ...

  3. JSP lifecycle - with servlet

    编译阶段: servlet容器编译servlet源文件,生成servlet类 初始化阶段: 加载与JSP对应的servlet类,创建其实例,并调用它的初始化方法 执行阶段: 调用与JSP对应的serv ...

  4. JVM调优总结(转)

    欢迎和大家交流技术相关问题: 邮箱: jiangxinnju@163.com 博客园地址: http://www.cnblogs.com/jiangxinnju GitHub地址: https://g ...

  5. bzoj题解汇总(1017-1020)

    bzoj1017: 树形dp. 设\(f[i][j][k]\)表示当前在点\(i\),有\(j\)个用于上层合成,花费金币为\(k\)的最大攻击力. bzoj1018: 一题多解. http://ww ...

  6. [Java] Java中List 去掉重复的值,并保持原先List顺序

    private List<YourBean> removeDuplicate(List<YourBean> list) { Set<YourBean> set = ...

  7. WebService是什么

    Webservice的一个最基本的目的就是提供在各个不同平台的不同应用系统的协同工作能力. 其实WebService并不是什么神秘的东西,它就是一个可以远程调用的类,或者说是组件. 为什么要使用Web ...

  8. sina 行情api

    http://blog.csdn.net/simon803/article/details/7784682

  9. WCF中Service Configuration Editor的使用方法

    1.在App.config文件上右击,选择Edit WCF Configuration.... 或者打开Program Files\Microsoft Visual Studio 8\Common7\ ...

  10. Reverse Nodes in k-Group [LeetCode]

    Problem Description: http://oj.leetcode.com/problems/reverse-nodes-in-k-group/ Basic Idea: Do it lik ...