先是依賴
compile 'com.facebook.fresco:fresco:1.5.0'
compile 'com.facebook.fresco:animated-gif:1.5.0'
首先需要註冊
public class App extends Application {
@Override
public void onCreate() {
super.onCreate();
Fresco.initialize(this);
}
}
然後是佈局呢
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="bwei.com.tupa.MainActivity">
<com.facebook.drawee.view.SimpleDraweeView
android:id="@+id/sdv"
android:layout_width="150dp"
android:layout_height="150dp" />
<!--<android.support.v7.widget.RecyclerView-->
<!--android:id="@+id/rlv"-->
<!--android:layout_width="match_parent"-->
<!--android:layout_height="match_parent"/>-->
</LinearLayout>
Activity裏的主頁面
private void initView() {
// mRlv = (RecyclerView) findViewById(R.id.rlv);
String ss = "http://c.hiphotos.baidu.com/image/w%3D500/sign=64d9fd84bc003af34dbadc60052bc619/37d12f2eb9389b501dc8fddf8f35e5dde7116e03.jpg";
mSdv = (SimpleDraweeView) findViewById(R.id.sdv);
DraweeController controller = Fresco.newDraweeControllerBuilder()
.setUri(Uri.parse(ss))
.setAutoPlayAnimations(true)
.build();
mSdv.setController(controller);
}