官方文档:http://fresco-cn.org/docs/index.html#
因为在Android Studio做开发,只简单介绍在其上的使用
1>引入Fresco
dependencies {
compile'com.facebook.fresco:fresco:0.5.0+'
}
2>使用 Fresco
在Application 初始化时
Fresco.initialize(this);
或者
Fresco.initialize(context);
在xml布局文件中, 加入命名空间:
<LinearLayout
xmlns:tools="http://schemas.android.com/tools"
xmlns:fresco="http://schemas.android.com/apk/res-auto"
加入SimpleDraweeView:
<com.facebook.drawee.view.SimpleDraweeView
android:id="@+id/sdv_iv"
android:layout_width="40dp"
android:layout_height="40dp"
fresco:placeholderImage="@mipmap/ic_launcher"/>
开始加载图片
Uri uri = Uri.parse("https://raw.githubusercontent.com/
liaohuqiu/fresco-docs-cn/docs/static/fresco-logo.png");
draweeView.setImageURI(uri);
剩下的,Fresco会替你完成:
显示占位图直到加载完成;
下载图片;
缓存图片;
图片不再显示时,从内存中移除;