Glide+RecyclerView卡在placeHolder視圖 , 不顯示加載成功圖片的問題


問題 : Glide 配合 RecyclerView 加載圖片時候第一次會經常顯示不出來圖片,問題代碼:

public void loadImage(@NonNull ImageView imageView, Object path, @DrawableRes int placeholder) {
        RequestOptions options = new RequestOptions()
                .centerCrop()
                .placeholder(placeholder);

        Glide.with(imageView.getContext())
                .load(path)
                .apply(options)
                .transition(DrawableTransitionOptions.withCrossFade())
                .into(imageView);
    }

解決方式:

注釋掉 Fade 動畫, 並調用 dontAnimate() 方法

public void loadImage(@NonNull ImageView imageView, Object path, @DrawableRes int placeholder) {
        RequestOptions options = new RequestOptions()
                .centerCrop()
                .placeholder(placeholder);

        Glide.with(imageView.getContext())
                .load(path)
                .apply(options)
//                .transition(DrawableTransitionOptions.withCrossFade())
                .dontAnimate()
                .into(imageView);
    }


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM