2
votes

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.

2
are u sure u are not setting background to imageview in xml - JAAD
No I am not using any background to the imageview in xm file. <ImageView android:id="@+id/thumbnail" android:layout_width="match_parent" android:adjustViewBounds="true" android:scaleType="fitCenter" android:layout_height="wrap_content" /> This is what I am using for imageView. - Prithniraj Nicyone
try removing scaleType or adjustViewBounds , are u sure u need this 2 property - JAAD

2 Answers

1
votes

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);
0
votes

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.