//得到imageloader实例;
ImageLoader instance = ImageLoader.getInstance();
iv = (ImageView) findViewById(R.id.iv);
//展示图片
instance.displayImage(urlBitmap,iv);
//ImageLoader的配置类;
ImageLoaderConfiguration imageLoaderConfiguration =
new ImageLoaderConfiguration.Builder(this).build();
//获取框架实例;
ImageLoader instance = ImageLoader.getInstance();
instance.init(imageLoaderConfiguration);
继承的是Application
public static DisplayImageOptions getDisplayImageOption() {
DisplayImageOptions options = new DisplayImageOptions.Builder()
.showImageOnFail(R.mipmap.ic_launcher) //配置默认图******
.showImageOnLoading(R.mipmap.ic_launcher)//配置默认图******
.showImageForEmptyUri(R.mipmap.ic_launcher)//配置默认图******
.bitmapConfig(Bitmap.Config.ARGB_8888)//配置图片解码格式,图片比较清晰 *****
.cacheInMemory(true) //是否缓存到内存 ******
.cacheOnDisk(true) //是否缓存到sd卡 ******
.displayer(new RoundedBitmapDisplayer(20))//*******是否设置为圆角,弧度为多少
.build();
return options;
}
public static DisplayImageOptions getDisplayImageOption2() {
DisplayImageOptions options = new DisplayImageOptions.Builder()
.showImageOnFail(R.mipmap.ic_launcher) //配置默认图******
.showImageOnLoading(R.mipmap.ic_launcher)//配置默认图******
.showImageForEmptyUri(R.mipmap.ic_launcher)//配置默认图******
.bitmapConfig(Bitmap.Config.ARGB_8888)//配置图片解码格式,图片比较清晰 *****
.cacheInMemory(true) //是否缓存到内存 ******
.cacheOnDisk(false) //是否缓存到sd卡 ******
.displayer(new RoundedBitmapDisplayer(20))//*******是否设置为圆角,弧度为多少
.build();
return options;
}
设置圆角,是否缓存到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"/>
<application
android:name=".MApp"
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>