ImageLoader加载图片工具类
来源:互联网 发布:python mat函数 编辑:程序博客网 时间:2024/05/17 12:55
第一步 :导依赖
compile files('libs/universal-image-loader-1.9.3-with-sources.jar')
第二步:加载图片工具类
public class MyApplic extends Application{ @Override public void onCreate() { super.onCreate(); //初始化IamgeLoader //获取sd卡根目录路径 File files = new File("/sdcard/Rimg"); initImageLoader(getApplicationContext(),files); } public static void initImageLoader(Context context,File file) { ImageLoaderConfiguration.Builder config = new ImageLoaderConfiguration.Builder(context); config.threadPriority(Thread.NORM_PRIORITY - 2); config.denyCacheImageMultipleSizesInMemory(); config.diskCacheFileNameGenerator(new Md5FileNameGenerator()); config.diskCacheSize(50 * 1024 * 1024); // 50 MiB config.tasksProcessingOrder(QueueProcessingType.LIFO); config.writeDebugLogs(); // Remove for release app config .diskCacheFileCount(50);//配置sdcard缓存文件的数量 // Initialize ImageLoader with configuration. ImageLoader.getInstance().init(config.build()); } @Override public void onConfigurationChanged(Configuration newConfig) { super.onConfigurationChanged(newConfig); } @Override public void onLowMemory() { super.onLowMemory(); }}
第三步:显示图片
DisplayImageOptions options = new DisplayImageOptions.Builder() .showImageOnLoading(R.mipmap.ic_launcher) //加载图片时的图片 .showImageForEmptyUri(R.mipmap.ic_launcher) //没有图片资源时的默认图片 .showImageOnFail(R.mipmap.ic_launcher) //加载失败时的图片 .cacheInMemory(true) //启用内存缓存 .cacheOnDisk(true) //启用外存缓存 .considerExifParams(true) //启用EXIF和JPEG图像格式 .displayer(new RoundedBitmapDisplayer(20)) //设置显示风格这里是圆角矩形 .build(); ImageLoader.getInstance().displayImage(list.get(i).getThumbnail_pic_s(),asd.img,options);
阅读全文
0 0
- ImageLoader加载图片工具类
- ImageLoader加载图片工具类
- ImageLoader加载本地图片的工具类
- ImageLoader加载图片的工具类
- 图片加载类ImageLoader
- ImageLoader 安卓异步加载图片开源工具类
- android ImageLoader加载本地图片的工具类(使用方法)
- android ImageLoader加载本地图片的工具类
- android ImageLoader加载本地图片的工具类
- android ImageLoader加载本地图片的工具类
- android ImageLoader加载本地图片的工具类
- android ImageLoader加载本地图片的工具类
- android ImageLoader加载本地图片的工具类
- ImageLoader图片加载的工具类基本使用
- android ImageLoader加载本地图片的工具类
- ImageLoader的加载工具类
- 分享github上的网络是否连接工具类NetWorkUtil及图片加载工具类ImageLoader
- ImageLoader加载网络图片初始化类
- HDU6213 Chinese Zodiac 签到 2017 ACM/ICPC Asia Regional Qingdao Online
- 博客开启
- 网络获取状态
- jni基础
- Markdown基本语法
- ImageLoader加载图片工具类
- 编译原理(2):文法和语言
- test2
- 梦幻古龙2.058商业端一键安装
- Hbase数据存储图解与数据检索流程
- 模糊查询和排序
- 【2017 ACM/ICPC Asia Regional Qingdao Online 1009】hdu 6214 Smallest Minimum Cut
- go语言包管理
- POJ