首先导入依赖
//Fresco的基础依赖 无论使用哪个模块的功能,都必须要添加
implementation 'com.facebook.fresco:fresco:1.5.0'
//下面的依赖根据需求,用到哪个模块,就导入对应的依赖即可.
// 仅支持 WebP 静态图,需要添加
implementation 'com.facebook.fresco:webpsupport:0.14.1'
// 支持 GIF 动图,需要添加
implementation 'com.facebook.fresco:animated-gif:1.5.0'
// 支持 WebP 静态图及 WebP 动图,需要添加
implementation 'com.facebook.fresco:animated-webp:0.14.1'
implementation 'com.facebook.fresco:webpsupport:0.14.1'
// 在 API < 14 上的机器支持 WebP 时,需要添加
implementation 'com.facebook.fresco:animated-base-support:0.14.1'
权限只需要加网络权限和读写权限 和全局配置
public void onCreate() {
super.onCreate();
Fresco.initialize(this);
}
布局加上xmlns:fresco=“http://schemas.android.com/apk/res-auto”
<com.facebook.drawee.view.SimpleDraweeView
android:layout_width="150dp"
android:layout_height="150dp
android:id="@+id/my_image_view"
fresco:placeholderImage="@mipmap/