Glide: When placeholder is replaced by image it keeps with the size of placeholder when using .override(size, size)

Created on 16 Jul 2015  路  5Comments  路  Source: bumptech/glide

Hello gentlemen,

I'm using your library on a listview to load images, these images are being transformed to fit the max width of my layout using _override_ but my placeholder have max dimensions for height/width; after dowloading and showing final image it keeps with the same size and aspect ratio than placeholder.

After doing scroll it appear with proper size.

                holder.mMultimediaLoadingProgress.setVisibility(View.VISIBLE);

                int size = (int) mContext.getResources().getDimension(R.dimen.chat_message_text_max_long); // 250dp

                Glide.with(mContext)
                        .load(msg.getMultimediaLink())
                        .placeholder(R.drawable.multimedia_placeholder)
                        .override(size, size)
                        .listener(new RequestListener<String, GlideDrawable>() {
                            @Override
                            public boolean onException(Exception e, String model, Target<GlideDrawable> target,
                                    boolean isFirstResource) {
                                holder.mMultimediaLoadingProgress.setVisibility(View.GONE);
                                return false;
                            }

                            @Override
                            public boolean onResourceReady(GlideDrawable resource, String model,
                                    Target<GlideDrawable> target,
                                    boolean isFromMemoryCache, boolean isFirstResource) {
                                holder.mMultimediaLoadingProgress.setVisibility(View.GONE);
                                return false;
                            }
                        })
                        .into(holder.mMsgImage);
                <ImageView
                    android:id="@+id/conversation_chat_list_item_msg_image"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:scaleType="fitCenter" />
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content" >

    <item>
        <shape
            xmlns:android="http://schemas.android.com/apk/res/android"
            android:shape="rectangle">
            <size
                android:width="@dimen/chat_message_text_max_long"
                android:height="@dimen/chat_message_text_max_long" />
        </shape>
    </item>

    <item>
        <bitmap android:src="@drawable/ic_file_image_box" android:gravity="center"/>
    </item>

</layer-list>

How can I manage this ?

Thanks a lot for you really good work, regards.

bug

Most helpful comment

Big thanks for the detailed report!
I think this is a duplicate of #386 and hence #363 or at least highly related. You can subscribe to #363 if you want updates.

Workaround is probably dontAnimate() or animate(fade_in) if this is caused by TransitionDrawable too and it seems so becuase after scroll there's no animation because it's cached.

All 5 comments

Big thanks for the detailed report!
I think this is a duplicate of #386 and hence #363 or at least highly related. You can subscribe to #363 if you want updates.

Workaround is probably dontAnimate() or animate(fade_in) if this is caused by TransitionDrawable too and it seems so becuase after scroll there's no animation because it's cached.

@TWiStErRob dontAnimate() fix this behavior, thanks a lot :)

dontAnimate() didn't solve my issue

This is my code

Glide.with(imgView.context)
    .load(imageUrl)
    .placeholder(placeholderImage)
    .dontAnimate()
    .into(imgView)

I'm using v4.11.0 of Glide.
Note: If I don't use the placeholder, image loads perfectly fine. My problem is exactly as the title of this issue describes.

dontAnimate() didn't solve my issue

This is my code

Glide.with(imgView.context)
  .load(imageUrl)
  .placeholder(placeholderImage)
  .dontAnimate()
  .into(imgView)

I'm using v4.11.0 of Glide.
Note: If I don't use the placeholder, image loads perfectly fine. My problem is exactly as the title of this issue describes.

Me too :/

dontAnimate() didn't solve my issue

Glide.with(context!!)
.load(url)
.apply(RequestOptions()
.placeholder(R.drawable.placeholder)
.error(R.drawable.error)
.dontAnimate()
)
.into(imgView)

I'm using --> com.github.bumptech.glide:glide:4.8.0

Note: If I don't use the placeholder, image loads perfectly fine. My problem is exactly as the title of this issue describes.

Was this page helpful?
0 / 5 - 0 ratings