Fresco 是一个强大的图片加载组件。
Fresco 是facebook推出的一款强大的android图片处理库,能够从网络,从本地文件系统,本地资源加载图片。为了最大限度节省空间和CPU时间,它含有3级缓存设计(2级内存,1级文件)。官方配置文档中文版 :http://fresco-cn.org/docs/index.html
直接上代码 –简单使用
1、导包,build.gradle里:
compile 'com.facebook.fresco:fresco:0.11.0'
2、在Aplication里提前实例化下:public class MyApplication extends Application { public static boolean b; @Override public void onCreate() { initImageLoader(getApplicationContext()); Fresco.initialize(getApplicationContext()); super.onCreate(); }} 注意:记得在Androidmanifest.xml清单文件中声明Aplication <application android:name=".MyApplication"…… 3、展示图片 ,用SimpleDraweeView <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:fresco="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" android:layout_height="match_parent"> <com.facebook.drawee.view.SimpleDraweeView android:id="@+id/image" android:layout_width="match_parent" android:layout_height="200dp" android:layout_margin="10dp" fresco:roundAsCircle="true" fresco:placeholderImage="@mipmap/ic_launcher" /> </LinearLayout> 如上:注意要选用fresco: 里的属性,需要导4.实例化控件:xmlns:fresco="http://schemas.android.com/apk/res-auto" 属性介绍展示: 大家也许添加控件的时候会出现如下:GenericDraweeView |