天天看点

Imageloader的默认加载图片或加载圆形图片的方法

这是默认的如果没有网的情况下加载什么样的图片

public static DisplayImageOptions getDefautOption() {

DisplayImageOptions imageOptions = new DisplayImageOptions.Builder()
            .showImageForEmptyUri(R.mipmap.ic_launcher)
            .showImageOnFail(R.mipmap.ic_launcher)
            .showImageOnLoading(R.mipmap.ic_launcher)
            .cacheInMemory(true)
            .cacheOnDisk(true)
            .imageScaleType(ImageScaleType.EXACTLY_STRETCHED)
            .resetViewBeforeLoading(true)//在加载之前复位一下显示
            .bitmapConfig(Bitmap.Config.RGB_565)//图片的质量
            .considerExifParams(true)///是否考虑JPEG图像EXIF参数(旋转,翻转)
            .build();
    return imageOptions;
}
           

这是默认的加载圆形的图片

public static DisplayImageOptions getCircleOption() {

DisplayImageOptions imageOptions = new DisplayImageOptions.Builder()

.showImageForEmptyUri(R.mipmap.ic_launcher)

.showImageOnFail(R.mipmap.ic_launcher)

.showImageOnLoading(R.mipmap.ic_launcher)

.cacheInMemory(true)

.cacheOnDisk(true)

.imageScaleType(ImageScaleType.EXACTLY_STRETCHED)

.resetViewBeforeLoading(true)//在加载之前复位一下显示

.bitmapConfig(Bitmap.Config.RGB_565)//图片的质量

.considerExifParams(true)///是否考虑JPEG图像EXIF参数(旋转,翻转)

.displayer(new CircleBitmapDisplayer())//圆形显示

.build();

return imageOptions;

}

这是加载圆角图片

public static DisplayImageOptions getBoundOption() {

DisplayImageOptions imageOptions = new DisplayImageOptions.Builder()

.showImageForEmptyUri(R.mipmap.ic_launcher)

.showImageOnFail(R.mipmap.ic_launcher)

.showImageOnLoading(R.mipmap.ic_launcher)

.cacheInMemory(true)

.cacheOnDisk(true)

.imageScaleType(ImageScaleType.EXACTLY_STRETCHED)

.resetViewBeforeLoading(true)//在加载之前复位一下显示

.bitmapConfig(Bitmap.Config.RGB_565)//图片的质量

.considerExifParams(true)///是否考虑JPEG图像EXIF参数(旋转,翻转)

.displayer(new RoundedBitmapDisplayer(20))//指定加载圆角的大小

.build();

return imageOptions;

}