Android – Loading images using Glide in Imageview

androidandroid-glideimageview

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.

Best Answer

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