fresco--facebook推出的一款强大的android图片处理库

来源:互联网 发布:java 线程池 编辑:程序博客网 时间:2024/05/24 02:48
先看效果图

参考资料:http://fresco-cn.org/docs/getting-started.html#_   
http://www.wfuyu.com/technology/23636.html
fresco是facebook推出的一款强大的android图片处理库, github地址:https://github.com/facebook/fresco 里面有官方的使用配置文档,而且是中文的。
一、加入引用
compile 'com.facebook.fresco:fresco:0.11.0'
二、fresco是通过控件来实现它内部的优化缓存处理,我们使用的时候是通过控件来使用,具体如下
<pre name="code" class="java"><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"    android:orientation="vertical">  <com.facebook.drawee.view.SimpleDraweeView        android:layout_width="match_parent"        android:layout_height="match_parent"        android:id="@+id/iv_player_head"        android:layout_centerVertical="true"        android:layout_marginStart="6dp"        android:layout_marginLeft="6dp"        app:roundAsCircle="true"// 是不是设置圆圈        fresco:placeholderImage="@drawable/head"//下载成功之前显示的图片        fresco:failureImage="@drawable/error"// 加载失败的时候显示的图片        fresco:retryImage="@drawable/trying"// 加载失败,提示用户点击重新加载的图片(会覆盖failureImage的图片)        fresco:progressBarImage="@drawable/progress"// 提示用户正在加载,和加载进度无关        fresco:progressBarImageScaleType="centerInside"        fresco:progressBarAutoRotateInterval="1000"        app:roundingBorderWidth="1dp"        app:roundingBorderColor="#FFFFFF"/>



三、代码中具体使用
<pre name="code" class="java"> Fresco.initialize(MainActivity.this);//初始化 setContentView(R.layout.activity_main); iv_player_head= (SimpleDraweeView) this.findViewById(R.id.iv_player_head);      iv_player_head.setImageURI(Uri.parse("http://avatar.csdn.net/5/D/9/1_vatty748895431.jpg"));

记得加权限<uses-permission android:name="android.permission.INTERNET" />
0 0