ImageLoader加载图片 默认方式和自定义方式
来源:互联网 发布:c语言的缺点 编辑:程序博客网 时间:2024/04/29 04:56
原文地址http://blog.csdn.net/zixinfei/article/details/50523921
public class MyApplication extends Application{
@Override
public void onCreate() {
// TODO Auto-generated method stub
super.onCreate();
//默认的方式
//ImageLoaderConfiguration configuration=ImageLoaderConfiguration.createDefault(this);
//sdcard的路径
String sdPath=Environment.getExternalStorageDirectory().getPath();
//自定义的方式
ImageLoaderConfiguration configuration=new ImageLoaderConfiguration.Builder(this)
.memoryCacheExtraOptions(480, 800)//内存缓存文件的最大长宽
.discCacheExtraOptions(480, 800, null)//本地缓存的详细信息
.threadPoolSize(3)//线程池内加载的数量
.threadPriority(Thread.NORM_PRIORITY-2)//设置当前线程的优先级
.tasksProcessingOrder(QueueProcessingType.FIFO)//设置任务的处理顺序
.denyCacheImageMultipleSizesInMemory()//防止内存中图片重复
.memoryCache(new LruMemoryCache(2*1024*1024))//设置自己的内存缓存大小 2M
.memoryCacheSize(2*1024*1024)
.memoryCacheSizePercentage(13)//内存缓存百分比
.discCache(new UnlimitedDiscCache(new File(sdPath+"/huang/image1")))//设置缓存的图片在sdcard中的位置
.discCacheSize(50*1024*1024)//硬盘缓存大小 50M
.discCacheFileCount(100)//硬盘缓存文件个数
.discCacheFileNameGenerator(new Md5FileNameGenerator())//md5加密的方式,或new HashCodeFileNameGenerator()
.imageDownloader(new BaseImageDownloader(this))
.imageDecoder(new BaseImageDecoder(true))//图片解码
.defaultDisplayImageOptions(getOption())//是否使用默认的图片加载配置,null表示不使用
.writeDebugLogs()
.build();
//初始化
ImageLoader.getInstance().init(configuration);
}
/*
* 设置option
*/
public static DisplayImageOptions getOption(){DisplayImageOptions option=new DisplayImageOptions.Builder()
.showImageOnLoading(R.drawable.ic_launcher)//设置图片下载期间显示的图片
.showImageForEmptyUri(R.drawable.emptyurl)//设置图片uri为空或是错误的时候显示的图片
.showImageOnFail(R.drawable.emptyurl)//设置图片加载或解码过程中发生错误显示的图片
.resetViewBeforeLoading(false)//设置图片在加载前是否重置、复位
//.delayBeforeLoading(1000)//下载前的延迟时间
.cacheInMemory(true)//设置下载的图片是否缓存在内存中
.cacheOnDisk(true)//设置下载的图片是否缓存在sd卡中
.considerExifParams(false)//思考可交换的参数
.imageScaleType(ImageScaleType.IN_SAMPLE_POWER_OF_2)//设置图片的显示比例
.bitmapConfig(Config.RGB_565)//设置图片的解码类型
.displayer(new RoundedBitmapDisplayer(40))//设置图片的圆角半径
.displayer(new FadeInBitmapDisplayer(3000))//设置图片显示的透明度过程的时间
.build();
return option;
}
}
0 0
- ImageLoader加载图片 默认方式和自定义方式
- ImageLoader加载图片 默认方式和自定义方式
- ImageLoader加载图片 默认方式和自定义方式
- Android imageloader加载网络,本地图片方式
- Android imageloader加载网络,本地图片方式
- Volley的ImageLoader加载图片错位处理方式
- android imageloader 两种加载图片方式的差异
- ImageLoader之加载不同来源的图片方式
- ImageLoader的各种加载方式
- 自定义ImageLoader实现GridView加载图片
- 自定义ImageLoader实现GridView加载图片
- ios-图片加载方式类别和优缺点
- android 加载图片方式
- android 加载图片方式
- xib加载图片方式
- 加载图片方式
- 图片预加载方式
- android 图片加载方式
- C++三种创建对象的方法区别
- 不少程序员都会碰到的三个面试题
- [文章摘要] 社会科学和公共政策的空间化和GIS的应用
- 这题90%的专科生都会做错
- Scala Actot(三):设计原则
- ImageLoader加载图片 默认方式和自定义方式
- linux limits.conf实验
- Spring源码分析【3】-SpingWebInitializer的加载
- Android BLE Beacon的探索
- 管理修改
- 如何发现优秀的开源项目?
- socket 通过 ioctl获取 设置 网卡 IP 子网掩码 本地广播地址
- POJ-2251 Dungeon Master
- Storage Options