天天看點

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;

}