2

I am using Glide library for loading images in imageview and using the below code.

Glide.with(mActivity)
                .load(img.getmGridViewImageUrl())
                .placeholder(R.color.grey_light)
                .into(imageHolder.imageView);

The placeholder with grey color gets visible until the image does not load but after the image get loads in imageview, the placeholder still take place and show some blank space after that image.

How can I resolve this issue. Please help me if you have any idea here.

Sam Judd
  • 7,317
  • 1
  • 38
  • 38
Prithniraj Nicyone
  • 5,021
  • 13
  • 52
  • 78

2 Answers2

1

Try this code.

When I give fix height to the ImageView it works for me.

Here's the layout

<ImageView 
    android:id="@+id/imgPoster"
    android:layout_width="fill_parent"
    android:layout_height="@dimen/height_of_getInspired_list"
    android:layout_centerVertical="true"
    android:scaleType="fitXY" 
    android:src="@drawable/default_image"/>

Here's my code.

Glide.with(this.context).load(inspiredList.get(position).image)
.error(R.drawable.default_image)
.centerCrop()
.crossFade()
.placeholder(R.drawable.default_image).into(holder.imgPoster);
Reaz Murshed
  • 23,691
  • 13
  • 78
  • 98
Andy Developer
  • 3,071
  • 1
  • 19
  • 39
  • I can not give the fix image height to imageview, I have to give wrap_content only to the imageview. – Prithniraj Nicyone Feb 01 '16 at 06:26
  • 3
    you can also try Picasso which is similar to Glide. http://square.github.io/picasso/ Glide library have a problem with some .jpeg file it becomes green colour or grey colour background. Please verify it with .png files. Also check the scale type FitXy it works for me – Andy Developer Feb 01 '16 at 06:33
0

Try this code.. This will help you..

Glide.with(this).load(photo_url)
            .crossFade()
            .thumbnail(0.5f)
            .diskCacheStrategy(DiskCacheStrategy.ALL)
            .placeholder(R.drawable.plaeholder_image)
            .listener(new RequestListener<String, GlideDrawable>() {
                @Override
                public boolean onException(Exception e, String model, Target<GlideDrawable> target, boolean isFirstResource) {
                    return false;
                }

                @Override
                public boolean onResourceReady(GlideDrawable resource, String model, Target<GlideDrawable> target, boolean isFromMemoryCache, boolean isFirstResource) {
                    imageView.setImageDrawable(resource);
                    return false;
                }
            })
            .into(imageView);

Please use placeholder image instead of color. you will able to use plain grey color image from drawable for placeholder image.

Mr.Sandy
  • 4,299
  • 3
  • 31
  • 54