依赖
implementation 'com.facebook.fresco:fresco:1.11.0'
在布局中写
<com.facebook.drawee.view.SimpleDraweeView
android:layout_width="150dp"
android:layout_height="150dp"
android:id="@+id/imagethree"
android:src="@mipmap/ic_launcher"/>
在APP里进行配置(别忘了在清单文件中注册)
//自定义缓存
DiskCacheConfig.Builder builder=DiskCacheConfig.newBuilder(this);
builder.setBaseDirectoryPath(new File(Environment.getExternalStorageDirectory().getAbsolutePath()+"/ima"));
DiskCacheConfig build=builder.build();
ImagePipelineConfig config=ImagePipelineConfig.newBuilder(this) .setDownsampleEnabled(true) .setMainDiskCacheConfig(build) .build();
Fresco.initialize(this,config);
adapter的使用
String icon = list.get(i).getIcon();
Uri uri= Uri.parse(icon);
((ThreeViewHolder) viewHolder).imageView.setImageURI(uri);