universal-image-loader的配置
来源:互联网 发布:网络远程教育 编辑:程序博客网 时间:2024/05/16 08:04
一般在application中设置基本的信息,在每个activity中根据需求配置具体的信息
ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(this)
.memoryCacheExtraOptions(480, 800)//设置每个缓存文件的最大长宽
.discCacheExtraOptions(480, 800, null)//保存到硬盘的每个文件的最大长宽
.threadPoolSize(3)//设置线程池内加载的数量
.threadPriority(Thread.NORM_PRIORITY - 2)
.denyCacheImageMultipleSizesInMemory()
.memoryCache(new UsingFreqLimitedMemoryCache(2 * 1024 * 1024))//设置内存缓存的最大大小(2M)
.discCacheSize(50 * 1024 * 1024)//硬盘缓存的最大大小(50M)
.discCacheFileNameGenerator(new Md5FileNameGenerator())//设置缓存的文件的名字以md5加密的方式保存到SD中
.tasksProcessingOrder(QueueProcessingType.LIFO)
.discCacheFileCount(100)//设置缓存文件的数量
.discCache(new UnlimitedDiskCache(new File(Environment.getExternalStorageDirectory() + “myapp/imgCache”)))//设置缓存文件的路径
.defaultDisplayImageOptions(getDisplayOptions())//加载图片的配置信息(也可以在每个页面根据不同的需求单独写)
.imageDownloader(new BaseImageDownloader(this, 5 * 1000, 30 * 1000))//设置链接,加载超时的时间
.writeDebugLogs()
.build();
ImageLoader.getInstance().init(config);
private DisplayImageOptions getDisplayOptions() {
DisplayImageOptions options;
options = new DisplayImageOptions.Builder()
.showImageOnLoading(R.mipmap.ic_launcher)//设置图片下载期间显示的图片
.showImageForEmptyUri(R.mipmap.ic_launcher)//设置Uri为空或是错误的时候显示的图片
.showImageOnFail(R.mipmap.ic_launcher)//设置图片加载/解码工程中错误的时候显示的图片
.cacheInMemory(true)//设置下载的图片是否缓存在内存中
.cacheOnDisc(true)//设置下载的图片是否缓存在SD卡中
.considerExifParams(true)//是否考虑JPEG图像EXIF参数(旋转,翻转)
.imageScaleType(ImageScaleType.EXACTLY_STRETCHED)//设置图片以如何的编码方式显示
.bitmapConfig(Bitmap.Config.RGB_565)//设置图片的解码类型
.resetViewBeforeLoading(true)//设置图片下载前是否重置,复位
.displayer(new RoundedBitmapDisplayer(20))//是否设置圆角,弧度为多少
.displayer(new FadeInBitmapDisplayer(100))//是否图片加载好后渐入的动画时间
.build();
return options;
}
getDisplayOptions()是在applicaiton中设置了具体的配置信息,在application中配置好的在使用的时候用 ImageLoader imageLoader = ImageLoader.getInstance()获取,用imageLoader .displayImage(url, imageview, Options)来展示;开发中一般很少这么做,因为每个界面的图片加载的需求不同,应该在每个界面找那个根据需求单独的配置,此时要在每个页面中DisplayImageOptions imageOptions = new DisplayImageOptions.Builder().showImageOnLoading(0)
.showImageForEmptyUri(0)
.showImageOnFail(0)
.cacheInMemory(true)
.cacheOnDisk(true)
.displayer(new RoundedBitmapDisplayer(0)).build();这么做重新new一个DisplayImageOptions ,可以根据不同的界面需求展示的图片也不同
- universal-image-loader的配置
- universal-image-loader 配置
- universal-image-loader 配置
- universal-image-loader 配置
- universal-image-loader 配置
- universal-image-loader 配置
- Universal-Image-Loader的使用
- Universal-Image-Loader的使用
- Universal-Image-Loader的使用
- universal-Image-Loader中ImageLoaderConfiguration的配置详解
- Android 开源框架Universal-Image-Loader的配置
- 自定义配置Universal-Image-Loader类数据的工具类
- Universal-Image-Loader配置详细说明
- Universal-Image-Loader系列1-配置使用
- Universal-Image-Loader 相关配置注释详解
- Universal Image Loader 学习笔记-框架配置
- android-universal-image-loader的使用
- 修复 Universal-image-loader 的几个Bug
- Android蓝牙通讯模块
- Android第一行代码学习笔记六----手机多媒体
- Windows下 Nginx+Tomcat6+Memcached反向代理负载均衡(HTTP+TCP)
- Web Service (四) 手动发布Web Service接口-CXF与Spring集成(实战)
- Qt中pro、pri文件的语法介绍
- universal-image-loader的配置
- VS编译器,代码生成设置中“/ML” 在VS2005的时候已经被移除了。
- asponse.cell读取excel内容
- 时间戳
- Web Service (二) CXF自动发布Web Service(No Spring)
- Linux 使用wget 命令下载JDK的方法
- 进化了这么久,大家都辛苦了
- 全屏切换效果
- 状态机