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