question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ImageView size not refreshed when loading from cache

See original GitHub issue

Hello,

I have an imageView as the following

<ImageView android:id="@+id/logo" android:layout_width="match_parent" android:layout_height="wrap_content" android:adjustViewBounds="true" android:layout_gravity="center_horizontal" />

When the image is loaded first time from the network the ImageView is rendred correctly and the height takes the height of the image. However when loading the Image the second time from the memory cache the imageView is not refreshed even if the image from the cache is there, the imageView height is not the same as the image.

Another scenario is if I set a placeholder, the second time the imageView keep the height the placeholder rather than the image loaded from the memory cache.

Any idea please ? I have already tried many workaround like invalidate the imageView on the callback but without success.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:6

github_iconTop GitHub Comments

1reaction
panwarabcommented, Mar 30, 2017

Ah! I see. Yeah, ViewTreeObservers are a good option if you want to check wether your layour has been drawn or not yet. 😃 Good to see it’s working now. 😃

0reactions
aeramlicommented, Mar 30, 2017

I have changed the addOnLayoutChangeListener to imageView.getViewTreeObserver().addOnGlobalLayoutListener and it is working fine now.

Thanks for help.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Refresh image cache in ImageView - android - Stack Overflow
I have an imageView from which I take visible part of image with getDrawingCache() . It works well. But when I change image...
Read more >
Best strategy to load images using Glide - Medium
Best Image Loading and Caching Strategy · ONE — Enable Disk Cache · TWO — Add Image Signature · THREE — Override Image...
Read more >
Launch Screen Image not Updating!!! | Apple Developer Forums
I am in the process of updating the app's Launch image. ... I found the solution is to remove the app on the...
Read more >
Loading and caching images from URL in SwiftUI - YouTube
In this tutorial I will show you how to load images from an URL. First, I will use AsyncImage, which was added for...
Read more >
Image QML Type | Qt Quick 6.4.1
If the width and height properties are not specified, the Image ... loaded asynchronously, and the progress and status properties are updated as...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found