-
Notifications
You must be signed in to change notification settings - Fork 6.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Recyclerview scrolling causes glide to lag when using wrap_content in the imageview #1088
Comments
At least one dimension must be fixed. To understand what's going on think about what you're currently asking Glide to do: here's a view that will grow as large as it needs to be, load an image into it. Glide's default behaviour is to read the size of the view and load a memory-efficient Bitmap into it. I hope you see the loop between "I'll grow!" and "what's your size?". Usually all you need to do is change one wrap to match in the layout XML, for example in a normal vertical list the width is match. You can drop the memory efficiency via Since in your case the view was already laid out, the previous image affected the view size and that size was kept even after removing the image and recognised by Glide later. So you need to reset your ImageView to just-inflated state, for example by applying |
Thank you. I was able to fix the caching issue by fixing the image size using override. I had another problem where the images were behaving oddly when scrolling very fast. Stuff like 1/8th of a previously scrolled image would overlap onto the bottom of my screen. Not entirely sure why but I suspect it was another resizing issue. Everything seems to be resolved after using PercentFrameLayout as seen here |
Scrolling and wraping in the same direction is a hard problem. The lists don't actually know how tall each item is because they vary. The scroller has only info about the currently visible bound items, and has to extrapolate from that. This is why the scrollbar jumps and the scrolling may look jumpy as well. Each item has to re-layout based on contents at every bind. I'm not sure I understand your 1/8 problem though, but you found a way. An interesting issue I found with wrap is that all items would be bound at startup at once, because all wrapped items started out as 0 tall, so all of them were "visible". |
Will this work with PercentRelativeLayout? Say I assigned a percentage height to an ImageView? |
When using wrap_content in the imageview, Glide's caching does not seem to work which causes a large amount of lag in the interface.
I am able to fix the issue by using a fixed size either through the xml or with the ".override" method for glide. But I'm wondering if there's a way to make wrap_content function correctly?
I am using glide 3.7.0 and okhttp 3.1.2
My recyclerview's onBindViewHolder is executing this line to use glide:
My recyclerview item is just a single imageview.
Full code here:
https://github.com/ryee1/tMDBAndroid/tree/master/app/src/main
The text was updated successfully, but these errors were encountered: