public class Net_ImageLoader extends Application {
@Override
public void onCreate() {
super.onCreate();
ImageLoaderConfiguration build = new ImageLoaderConfiguration.Builder(this)
//缓冲目录
.diskCache(new UnlimitedDiskCache(new File(getCacheDir(),"image")))
//缓冲到磁盘
.diskCache(new UnlimitedDiskCache(new File(Environment.getExternalStorageDirectory(),"image")))
//设置圆角
.displayer(new CircleBitmapDisplayer(360))
.build();
ImageLoader instance = ImageLoader.getInstance();
instance.init(build);
}
适配器里写
displayImageOptions = new DisplayImageOptions.Builder()
//为空或请求的资源不存在
.showImageForEmptyUri(R.mipmap.ic_launcher)
//缓存
.cacheOnDisk(true)
//使用缓存
.cacheInMemory(true)
//设置图片的类型
.bitmapConfig(Bitmap.Config.RGB_565)
.build();