<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                企業??AI智能體構建引擎,智能編排和調試,一鍵部署,支持知識庫和私有化部署方案 廣告
                [TOC] ## 下載Fresco 類庫發布到了Maven中央庫: ### Gradle: ~~~groovy dependencies { compile 'com.facebook.fresco:fresco:0.1.0+' } ~~~ ### Maven: ~~~xml <dependency> <groupId>com.facebook.fresco</groupId> <artifactId>fresco</artifactId> <version>LATEST</version> </dependency> ~~~ ### Eclipse ~~~呵呵~~~ ## 配置和開始使用 如果你僅僅是想簡單下載一張網絡圖片,在下載完成之前,顯示一張占位圖,那么簡單使用 SimpleDraweeView 即可。 在Application 初始化時: ~~~java Fresco.initialize(context);~~~ 在xml布局文件中, 加入命名空間: ~~~xml <!-- 其他元素 --> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:fresco="http://schemas.android.com/apk/res-auto"> ~~~ 加入`SimpleDraweeView`: ~~~xml <com.facebook.drawee.view.SimpleDraweeView android:id="@+id/my_image_view" android:layout_width="20dp" android:layout_height="20dp" fresco:placeholderImage="@drawable/my_drawable" /> ~~~ 開始加載圖片 ~~~ draweeView.setImageURI("http://site.com/uri"); ~~~ 剩下的,Fresco會替你完成: - 顯示占位圖直到加載完成; - 下載圖片; - 緩存圖片; - 圖片不再顯示時,從內存中移除; 等等等等。 ## 關鍵概念 ### Drawees Drawees 負責圖片的呈現,包含幾個組件,有點像MVC模式。 #### DraweeView 繼承于 [View](http://developer.android.com/reference/android/view/View.html), 負責圖片的顯示。 一般情況下,使用`SimpleDraweeView` 即可. 簡單的用法,在這個頁面:[開始使用](#) 。 它支持很多自定義效果,參見這里: [自定義顯示效果](#). #### DraweeHierarchy 繼承于 Drawable, 包含用于繪制的圖像數據。MVC中的M。 如果你想在Java代碼中自定義圖片的展示,可以通過這類實現,具體的請參考這里: [在Java代碼中自定義顯示效果](#) #### DraweeController `DraweeController` 負責和 image loader 交互(默認是Fresco中 image pipeline),可以創建一個這個類的實例,來實現對所要顯示的圖片做更多的控制。 #### DraweeControllerBuilder `DraweeControllers` 由 `DraweeControllerBuilder` 采用 Builder 模式創建,創建之后,不可修改。具體參見: [使用ControllerBuilder](#)。 #### Listeners 使用 ControllerListener 的一個場景就是設置一個 [Listener](#)監聽圖片的下載。 ### Image Pipeline Fresco 的 Image Pipeline 負責圖片的獲取和管理。圖片可以來自遠程服務器,本地文件,或者Content Provider,本地資源。壓縮后的文件緩存在本地存儲中,Bitmap數據緩存在內存中。 在5.0系統之后,Image Pipeline 使用`pinned purgeables*將Bitmap數據存在native 內存中。這要求圖片不使用時,要顯示地釋放內存。 `SimpleDraweeView` 自動處理了這個釋放過程,所以沒有特殊情況,盡量使用`SimpleDraweeView`,在特殊的場合,如果有需要,也可以直接控制Image Pipeline。 ## 支持的URIs Fresco 支持許多URI格式。 特別注意:Fresco **不支持** 相對路徑的URI. 所有的URI都必須是絕對路徑,并且帶上該URI的scheme。 如下: | 類型 | Scheme | 示例 | |-----|-----|-----| | 遠程圖片 | `http://,``https://` | `HttpURLConnection` 或者參考 [使用其他網絡加載方案](#) | | 本地文件 | `file://` | `FileInputStream` | | Content provider | `content://` | `ContentResolver` | | asset目錄下的資源 | `asset://` | `AssetManager` | | res目錄下的資源 | `res://` | `Resources.openRawResource` | 注意,只有圖片資源才能使用在Imagepipeline中,比如(PNG)。其他資源類型,比如字符串,或者XML Drawable在Imagepipeline中沒有意義。所以加載的資源不支持這些類型。 像ShapeDrawable這樣聲明在XML中的drawable可能引起困惑。注意到這畢竟不是圖片,如果想把這樣的drawable作為圖像顯示。 那么把這個drawable設置為占位圖,然后把URI設置為null。
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看