ImageLoader的基础使用
来源:互联网 发布:php开发手册 编辑:程序博客网 时间:2024/06/05 23:06
1--权限(联网,读写sd卡)
<uses-permission android:name="android.permission.INTERNET" /><uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/><uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
2--依赖 compile 'com.nostra13.universalimageloader:universal-image-loader:1.9.5'
*onCreate中
ImageLoaderConfiguration configuration = new ImageLoaderConfiguration.Builder(this).build();
//获取ImageLoader的实例初始化配置参数;
ImageLoader.getInstance().init(configuration);
4 调用
ImageLoader instance = ImageLoader.getInstance();
instance.displayImage(urlBitmap,iv);
全局类配置
public class MApp extends Application{ File cacheFile= new File(Environment.getExternalStorageDirectory()+"/"+"imgages"); @Override public void onCreate() { super.onCreate(); //初始化组件,链式开发思想,整个框架的参数初始化配置 ImageLoaderConfiguration configuration = new ImageLoaderConfiguration.Builder(this) .memoryCacheExtraOptions(480, 800) // default = device screen dimensions 内存缓存文件的最大长宽 .diskCacheExtraOptions(480, 800, null) // 本地缓存的详细信息(缓存的最大长宽),最好不要设置这个 .tasksProcessingOrder(QueueProcessingType.FIFO) // default .denyCacheImageMultipleSizesInMemory() .memoryCache(new LruMemoryCache(2 * 1024 * 1024)) //可以通过自己的内存缓存实现 .memoryCacheSize(2 * 1024 * 1024) // 内存缓存的最大值 .memoryCacheSizePercentage(13) // default .diskCacheSize(50 * 1024 * 1024) // 50 Mb sd卡(本地)缓存的最大值 .diskCacheFileCount(100) // 可以缓存的文件数量 .diskCache(new UnlimitedDiskCache(cacheFile))//自定义缓存目录 // default为使用HASHCODE对UIL进行加密命名, 还可以用MD5(new Md5FileNameGenerator())加密 .diskCacheFileNameGenerator(new HashCodeFileNameGenerator()) .defaultDisplayImageOptions(DisplayImageOptions.createSimple()) // default .writeDebugLogs() // 打印debug log .build(); ImageLoader.getInstance().init(configuration); }}
图片展示配置
public class ImageLoaderUtils_circle { public static DisplayImageOptions getDisplayImageOption() { DisplayImageOptions options = new DisplayImageOptions.Builder() .showImageOnLoading(R.mipmap.ic_launcher) //设置图片在下载期间显示的图片 .showImageForEmptyUri(R.mipmap.ic_launcher)//设置图片Uri为空或是错误的时候显示的图片 .showImageOnFail(R.mipmap.ic_launcher) //设置图片加载/解码过程中错误时候显示的图片 .cacheInMemory(true)//设置下载的图片是否缓存在内存中 .cacheOnDisk(true) .considerExifParams(true) //是否考虑JPEG图像EXIF参数(旋转,翻转) .imageScaleType(ImageScaleType.EXACTLY_STRETCHED)//设置图片以如何的编码方式显示 .bitmapConfig(Bitmap.Config.RGB_565)//设置图片的解码类型// .displayer(new RoundedBitmapDisplayer(5))//是否设置为圆角,弧度为多少// .displayer(new FadeInBitmapDisplayer(100))//是否图片加载好后渐入的动画时间 .build();//构建完成 return options; }}
参考资料
http://blog.csdn.net/vipzjyno1/article/details/23206387
http://blog.csdn.net/hudashi/article/details/52026798
https://github.com/nostra13/Android-Universal-Image-Loader
阅读全文
0 0
- imageloader的基础使用
- ImageLoader的基础使用
- ImageLoader的基础使用
- ImageLoader的基础使用
- ImageLoader的基础使用
- ImageLoader的基础使用
- ImageLoader基础使用
- ImageLoader的使用
- ImageLoader的使用
- 开源库ImageLoader的使用
- ImageLoader的基本使用
- ImageLoader的使用
- ImageLoader的使用
- ImageLoader的简单使用
- ImageLoader的基本使用
- imageloader的简单使用
- ImageLoader的使用
- ImageLoader的使用
- Imagge配置缓存本地文件夹
- 网络安全相关网站
- 模块API之lookup_module_symbol_name
- Zabbix Ubuntu 环境下配置
- Linux Cmake静态库链接
- ImageLoader的基础使用
- 修改Hyperion Planning应用所有者
- jsonp回调
- glog install error
- 一些零散笔记
- kernel中数组元素赋初值
- 如何写软件概要设计?
- SpringMVC默认访问首页配置及web.xml配置
- 解决ScrollView下的子控件无法居中