最新的Fresco加載Gif圖片

先是依賴

    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);
    }

這裏寫圖片描述
這裏寫圖片描述

發佈了37 篇原創文章 · 獲贊 27 · 訪問量 45萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章