build.gradle中引入jar包
compile 'com.facebook.fresco:fresco:1.5.0'
layout中xml文件
<?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" android:layout_height="match_parent"> <LinearLayout android:layout_width="match_parent" android:layout_height="180dp" android:orientation="horizontal" android:weightSum="4" android:background="@mipmap/userbg_02"> <LinearLayout android:layout_width="0dp" android:layout_height="match_parent" android:gravity="center" android:layout_weight="1.3"> <com.facebook.drawee.view.SimpleDraweeView android:id="@+id/sdv_surface" android:layout_width="110dp" android:layout_height="110dp" app:failureImageScaleType="centerInside" app:placeholderImageScaleType="fitCenter" app:progressBarAutoRotateInterval="1000" app:progressBarImageScaleType="centerInside" app:retryImageScaleType="centerInside" app:roundedCornerRadius="30dp" app:roundingBorderWidth="2dp" app:roundingBorderColor="@color/white" app:fadeDuration="1000" app:pressedStateOverlayImage="@color/colorPrimary" android:onClick="onClick" android:src="@mipmap/jcss_03" app:roundAsCircle="true" /> </LinearLayout> </LinearLayout> </RelativeLayout>
使用
在Application实例化
//全局初始化Fresco Fresco.initialize(this);
调用
draweeView = (SimpleDraweeView) findViewById(R.id.draweeView); String imageUrl = "http://www.pp3.cn/uploads/201511/2015111212.jpg"; //加载图片 draweeView.setImageURI(imageUrl);