简体   繁体   中英

Glide Image showing Blur in fragment

I use glide in fragment using recycler view but images are not showing properly.

please suggest me to slove this issue

 Glide.with(context)
     .load( image_url)
     .placeholder(R.drawable.pic)
     .error(R.drawable.pic)
     .fitCenter()
     .into(Viewholder.imageView);

By default Glide uses low resolution images to save data and improve performance.

boolean isHighResolution = true;

 BitmapRequestBuilder<String, Bitmap> builder = Glide
                .with(this)
                .load(url)
                .asBitmap()
                .format(isHighResolution
                        ? DecodeFormat.PREFER_ARGB_8888
                        : DecodeFormat.PREFER_RGB_565)
builder.into(imageView);

You can try this code, and see if this helps.

The image to be loaded size should be greater and doesn't loaded properly and it is blurred. use Bitmap and compress the image like below

Glide.with(mContext)
        .load(album.getBannerUrl())
        .asBitmap()
        .diskCacheStrategy(DiskCacheStrategy.ALL)
        .into(new SimpleTarget<Bitmap>() {
            @Override
            public void onResourceReady(Bitmap bitmap, GlideAnimation anim) {
                // Do something with bitmap here.
                holder3.headerimage.setImageBitmap(bitmap);
                Glide.with(mContext)
                        .load(album.getBannerUrl().get(0))
                        .asBitmap()
                        .diskCacheStrategy(DiskCacheStrategy.ALL)
                        .into(new SimpleTarget<Bitmap>() {
                            @Override
                            public void onResourceReady(Bitmap bitmap, GlideAnimation anim) {
                                // Do something with bitmap here.
                                holder3.headerimage.setImageBitmap(bitmap);
                            }
                        });
            }
        });

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM