Skip to content Skip to sidebar Skip to footer

Loading Images Using Glide In Imageview

I am using Glide library for loading images in imageview and using the below code. Glide.with(mActivity) .load(img.getmGridViewImageUrl()) .placehol

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

Solution 2:

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(newRequestListener<String, GlideDrawable>() {
                @OverridepublicbooleanonException(Exception e, String model, Target<GlideDrawable> target, boolean isFirstResource) {
                    returnfalse;
                }

                @OverridepublicbooleanonResourceReady(GlideDrawable resource, String model, Target<GlideDrawable> target, boolean isFromMemoryCache, boolean isFirstResource) {
                    imageView.setImageDrawable(resource);
                    returnfalse;
                }
            })
            .into(imageView);

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

Post a Comment for "Loading Images Using Glide In Imageview"