鍍金池/ 教程/ Android/ 引入Fresco
進(jìn)度條
在JAVA代碼中使用Drawees
Drawee的各種效果配置
緩存
一些陷阱
關(guān)于在Android Studio中編譯
多圖請求及圖片復(fù)用
自定義網(wǎng)絡(luò)加載
支持的URIs
可關(guān)閉的引用
監(jiān)聽下載事件
修改圖片
引入Fresco
縮放
圓角和圓圈
配置Image Pipeline
縮放和旋轉(zhuǎn)圖片
(圖片請求)Image Requests
自定義View
使用ControllerBuilder
在XML中使用Drawees
開始使用 Fresco
關(guān)鍵概念
Image Pipeline介紹
漸進(jìn)式JPEG圖
數(shù)據(jù)源和數(shù)據(jù)訂閱者
直接使用Image Pipeline
動畫圖(gif)
使用其他的Image Loader

引入Fresco

本教程內(nèi)容來源于:http://fresco-cn.org
采用 知識共享 署名 4.0 國際 許可協(xié)議 進(jìn)行許可

類庫發(fā)布到了Maven中央庫:

1.Android Studio 或者 Gradle

dependencies {
  compile 'com.facebook.fresco:fresco:0.6.0+'
}

2.Intellij IDEA 或者 Maven:

這是一個在 Intellij IDEA 的工程簡單示例: ,可供參考。

這個 issue 解決之前,pom 中相關(guān)依賴缺少 type 字段,通過以下方式無法直接引入:

<dependency>
  <groupId>com.facebook.fresco</groupId>
  <artifactId>fresco</artifactId>
  <version>LATEST</version>
</dependency>

需要這樣:

<!-- use this version, exclude all the other version from the other libraries. -->
<dependency>
    <groupId>com.android.support</groupId>
    <artifactId>support-v4</artifactId>
    <version>21.0.3</version>
    <type>aar</type>
</dependency>

<!-- begin of fresco -->
<dependency>
    <groupId>com.facebook.fresco</groupId>
    <artifactId>fresco</artifactId>
    <version>0.6.0</version>
    <type>aar</type>
    <exclusions>
        <exclusion>
            <groupId>com.android.support</groupId>
            <artifactId>support-v4</artifactId>
        </exclusion>
        <exclusion>
            <groupId>com.facebook.fresco</groupId>
            <artifactId>*</artifactId>
        </exclusion>
    </exclusions>
</dependency>
<dependency>
    <groupId>com.facebook.fresco</groupId>
    <artifactId>fbcore</artifactId>
    <type>aar</type>
    <version>0.6.0</version>
</dependency>
<dependency>
    <groupId>com.facebook.fresco</groupId>
    <artifactId>drawee</artifactId>
    <type>aar</type>
    <version>0.6.0</version>
    <exclusions>
        <exclusion>
            <groupId>com.android.support</groupId>
            <artifactId>support-v4</artifactId>
        </exclusion>
        <exclusion>
            <groupId>com.facebook.fresco</groupId>
            <artifactId>fbcore</artifactId>
        </exclusion>
    </exclusions>
</dependency>
<dependency>
    <groupId>com.facebook.fresco</groupId>
    <artifactId>imagepipeline</artifactId>
    <type>aar</type>
    <version>0.6.0</version>
    <exclusions>
        <exclusion>
            <groupId>com.android.support</groupId>
            <artifactId>support-v4</artifactId>
        </exclusion>
        <exclusion>
            <groupId>com.facebook.fresco</groupId>
            <artifactId>fbcore</artifactId>
        </exclusion>
    </exclusions>
</dependency>
<!-- end of fresco -->

很丑陋對吧,抱歉目前暫時只能這樣,有更好的辦法請一定告訴我。

刷新 Maven 工程,下載引用,下載完成之后,將:

gen-external-apklibs/com.facebook.fresco_imagepipeline_{版本號}/jni

目錄下的三個文件夾:armeabi,armeabi-v7a,x86 這三個文件夾拷貝到 libs 文件夾下。

3. Eclipse ADT

首先,下載這個文件.

解壓后,你會看到一個目錄:frescolib,注意這個目錄。

  1. 從菜單 "文件(File)",選擇導(dǎo)入(Import)
  2. 展開 Android, 選擇 "Existing Android Code into Workspace", 下一步。
  3. 瀏覽,選中剛才解壓的的文件中的 frescolib 目錄。
  4. 這5個項目應(yīng)該都會被添加到工程: drawee, fbcore, fresco, imagepipeline, imagepipeline-okhttp。請確認(rèn)前4個項目一定是被選中的。點擊完成。
  5. 右鍵,項目,選擇屬性,然后選擇 Android。
  6. 點擊右下角的 Add 按鈕,選擇 fresco,點擊 OK,再點擊 OK。

現(xiàn)在,fresco 就導(dǎo)入到項目中了,你可以開始編譯了。如果編譯不通過,可以嘗試清理資源,或者重啟 Eclipse。

如果你想在網(wǎng)絡(luò)層使用 OkHttp,請看[這里][3].

如果 support-v4 包重復(fù)了,刪掉 frescolib/imagepipeline/libs 下的即可。

建議盡早使用 Android Studio。