When I load the image into the ImageView
with Glide
, it shrinks the image. When I rotate or reopen the same activity it has the right size. I already tried possible duplicate. I am already passing fix size to the ImageView
inside the xml and I tried to override the size as well. centerCrop()
and fitCenter()
has no effect on the shrink.
I also tried to debug the image size. When it is shrinked or not it returns same width and height.
View:
<ImageView
android:id="@+id/thumbnail"
android:layout_width="@dimen/episode_detail_img_width"
android:layout_height="@dimen/episode_detail_img_height"
android:layout_marginTop="@dimen/episode_detail_img_margin_top" />
Glide
Glide.with(getActivity())
.load(url)
.placeholder(R.drawable.thumb_placeholder)
.centerCrop()
.diskCacheStrategy(DiskCacheStrategy.ALL)
.into(thumbnail);
You click sync in Glide If you are building your project in Glide and need to see the latest data from your data source, you can click the sync button.
I am glade you got your answer. Just for more description of your problem is :
Glide calculated your ImageView height and width before starting a load of an image but when an image gets load it replace your placeholder drawable. so if your placeholder drawable height or weight is small, Glide will render downloaded bitmap with placeholder's dimension.
So, for no lag in different screen size and layout, I advise using high dimension drawable in a placeholder.
And one more hack is that use color in a placeholder because color has no height or width, so render in the whole area of the view.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With