天天看點

學習筆迹——DisplayImageOptions,網絡圖檔顯示

DisplayImageOptions用于指導每一個Image根據網絡圖檔的狀态(空白、下載下傳錯誤、正在下載下傳)顯示對應的圖檔,是否将緩存加載到磁盤上,下載下傳完後對圖檔進行怎麼樣的處理。

//設定圖檔在下載下傳期間顯示的圖檔       showStubImage(R.drawable.ic_launcher)

     //設定圖檔Uri為空或是錯誤的時候顯示的圖檔      showImageForEmptyUri(R.drawable.ic_empty)

     //設定圖檔加載/解碼過程中錯誤時候顯示的圖檔      showImageOnFail(R.drawable.ic_error)

    //設定圖檔在下載下傳前是否重置,複位      resetViewBeforeLoading()

    //設定下載下傳的圖檔是否緩存在記憶體中    cacheInMemory()

    //設定下載下傳的圖檔是否緩存在SD卡中     cacheOnDisc()

  //設定圖檔的解碼類型     bitmapConfig(Bitmap.Config.RGB_565)

   //設定圖檔的解碼配置     decodingOptions(android.graphics.BitmapFactory.Options decodingOptions)

   //設定圖檔下載下傳前的延遲     delayBeforeLoading(int delayInMillis) 

    //設定額外的内容給ImageDownloader     extraForDownloader(Object extra)

   //設定圖檔加入緩存前,對bitmap進行設定     preProcessor(BitmapProcessor preProcessor)

   //設定顯示前的圖檔,顯示後這個圖檔一直保留在緩存中     postProcessor(BitmapProcessor postProcessor)  --------------------------   

   //設定圖檔以如何的編碼方式顯示      imageScaleType(ImageScaleType imageScaleType)

        // 建立預設的DisplayImageOptions         DisplayImageOptions option_0 = DisplayImageOptions.createSimple();

        // 使用DisplayImageOptions.Builder()建立DisplayImageOptions         DisplayImageOptions option_1 = new DisplayImageOptions.Builder()                 .showStubImage(R.drawable.ic_launcher)                 .showImageOnFail(R.drawable.ic_error)                 .showImageForEmptyUri(R.drawable.ic_empty).cacheInMemory()                 .cacheOnDisc().displayer(new RoundedBitmapDisplayer(20))                 .build();

  ---------------       displayer(BitmapDisplayer displayer)

    displayer:

              RoundedBitmapDisplayer(int roundPixels)設定圓角圖檔               FakeBitmapDisplayer()這個類什麼都沒做               FadeInBitmapDisplayer(int durationMillis)設定圖檔漸顯的時間          SimpleBitmapDisplayer()正常顯示一張圖檔  

-----------------------

    imageScaleType(ImageScaleType imageScaleType)     imageScaleType:                    EXACTLY :圖像将完全按比例縮小的目标大小                    EXACTLY_STRETCHED:圖檔會縮放到目标大小完全                    IN_SAMPLE_INT:圖像将被二次采樣的整數倍                    IN_SAMPLE_POWER_OF_2:圖檔将降低2倍,直到下一減少步驟,使圖像更小的目标大小                    NONE:圖檔不會調整