直播平臺製作,Glide載入網路圖,進度條顯示

zhibo系統開發發表於2023-10-23

直播平臺製作,Glide載入網路圖,進度條顯示

1,首先在build.gradle新增依賴 compile ‘com.github.bumptech.glide:glide:3.7.0’

2,我就直接複製程式碼了:

//顯示圖片
Glide.with(getContext())
                    .load(content)
                   .into(new ImageViewTarget<GlideDrawable>(iv_pic) {
                       //               圖片開始載入
                       @Override
                       public void onLoadStarted(@Nullable Drawable placeholder) {
                           super.onLoadStarted(placeholder);
                           Log.d("info", "圖片開始載入");
                           dialog.show();
                       }
                       @Override
                       public void onLoadFailed(Exception e, Drawable errorDrawable) {
                           super.onLoadFailed(e, errorDrawable);
                           Log.d("info", "圖片載入失敗");
                           dialog.dismiss();
                       }
                       @Override
                       protected void setResource(GlideDrawable resource) {
                           Log.d("info", "圖片設定資源");
                       }
                       @Override
                       public void onResourceReady(GlideDrawable resource, GlideAnimation<? super GlideDrawable> glideAnimation) {
                           super.onResourceReady(resource, glideAnimation);
                           dialog.dismiss();
                           iv_pic.setImageDrawable(resource);
                           Log.d("info", "圖片載入完成");
                       }
                   });


3,然後我還要說的是我遇到的坑, 注意匯入的包 不能出錯,如下:

import android.graphics.drawable.Drawable;
import com.bumptech.glide.Glide;
import com.bumptech.glide.load.resource.drawable.GlideDrawable;
import com.bumptech.glide.request.animation.GlideAnimation;
import com.bumptech.glide.request.target.ImageViewTarget;
import javax.annotation.Nullable;


 以上就是 直播平臺製作,Glide載入網路圖,進度條顯示,更多內容歡迎關注之後的文章


來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/69978258/viewspace-2990442/,如需轉載,請註明出處,否則將追究法律責任。

相關文章