-
Notifications
You must be signed in to change notification settings - Fork 4k
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
Placeholder is stretched before updating the ImageView (2.2.0) #427
Comments
Having the same problem. scaleType doesn't seem to have any effect. The only way to work around the problem I found is to have placeholder images exactly the same size as the ImageView. That means several versions (or sets of images in case of animations) for different sizes - very ugly. And of course you don't always know the size. |
You should call resize() or resizeDimen() after load(url). Picasso needs specific bounds before "centerCrop" or "centerResize" to prevent distortion of the aspect ratio. |
I've noticed that this still seems to be happening in the latest Picasso. If the ImageView is |
Yes. |
I guess I'm a bit confused, then, why it changes size. If it doesn't honor |
Ah, sorry for not elaborating. We set the placeholder directly on the The fix would be to copy |
Ah, that falls in line with something else I just discovered, which was that using I might look into doing a PR to do what you propose; seems like it should be possible in any case where it's being loaded into an |
@JakeWharton I've been investigating the issue and duplicating I'm looking at it from another angle now: why is The downside would be wrecking everyone's code that depends on |
I would have to dig up old threads to see all the reasons. In the interest of replying sooner rather than later, one of them was that it reduced our allocations by 1 or 2 per successful image download. Since many images usually comprise a screen we try to be conscious about allocation. That said, fixing something like this would be worth undoing that and chasing allocations elsewhere. |
For the sake of moving things along, I tried implementing There are a fair number more allocations by using |
I've been digging into a solution to this (that doesn't involve The
The core problem is that the intrinsic width/height often changes when switching from the placeholder to the actual image. This causes the matrix to change, which in turn distorts the placeholder. This also means that the The only solution, as I see it, would be to pre-configure the placeholder with the future image's intrinsic width/height. This means the placeholder wouldn't shift when it's rendered along with the image (later on). It would only work properly if you are using something like |
That sounds correct. Did you attempt a fix/update in |
I threw something ugly together quickly that proved it solved the problem, but nothing I'd send as a PR. :) I'll have time next week to work on a good solution. The issue I ran into was that currently the placeholder is set immediately, but in order for it to work with |
Thank you man. We're on the same boat here with respect to "having more time". |
I took another look at it and now I'm conflicted. If we fix the aspect ratio of the placeholder when cross-fading (by having the placeholder match the aspect ratio of the loaded image), that means the placeholder's ratio will be wrong. For example, if the placeholder is a rectangle, but the requested size is a square, then the placeholder will be squished into a square aspect ratio. Now the placeholder won't suddenly warp during the crossfade, but it'll look wrong the entire time the image is loading, which is just as bad. If you want to see it in action, I've got a branch with it working here: https://github.com/dlew/picasso/tree/dlew/placeholder-fix I suspect the only way to properly solve this dilemma would be to have a custom I would love some guidance on what you think is best here. |
I hope this issue will be fixed some day. |
So do I. |
noFade() can fix overlap problem when use placeholder |
soooooome day |
I am using framelayout to show placeholder image in center, with second layer for picasso image to load. Works like charm. |
Hello guys, my current solution to this is to use a scaleType= "center" or the one required for the placeHolder to be displayed correctly. Implement the Target in the activity or fragment and then do something like this (previously instantiating the ImageView in the activity or fragment): @OverRide
|
Am I right to say that because of this issue, the "fading" feature of Picasso is not really currently usable? Or is there something I'm missing? |
Use placeholders that are sized with the same aspect ratio as the target On Sat, Jan 23, 2016, 1:20 PM Benoit Lubek notifications@github.com wrote:
|
Ok thank you for your answer, @JakeWharton. In my current case it's not really possible since my ImageView's width is the screen's width (depends on the device) whereas its height is fixed. |
What's the placeholder? That sounds like a great case for a 9-patch. Even On Sat, Jan 23, 2016, 1:25 PM Benoit Lubek notifications@github.com wrote:
|
@JakeWharton Currently my placeholder is not a 9-patch, I didn't think about it. I will try that and see if it works as intended, thank you. |
How can the placeholder be the same size as the target image if the target image hasn't downloaded it yet? The size is unknown. |
Rarely are you loading an image and letting its size dictate the size of On Wed, Sep 14, 2016 at 6:10 PM martymiller notifications@github.com
|
I found a solution that works for this issue |
@donUA It works thanks dude ;) |
Opened in 2014, now we are almost in 2020, still open! |
almost 2023 and still open, it happens in my app, can not use a placeholder with same aspect ratio of the target image. Using noFade() workaround. UPDATE: found an interesting alternative, wrapping the placeholder drawable in this CenterCropDrawable fixes the issue https://gist.github.com/rudchenkos/e33dc0d6669a61dde9d6548f6c3e0e7e |
In version 2.2.0 the placeholder image is stretched right before being replaced with the actual image. It looks ugly. In previous version 2.1.1, this worked as expected. Here is the relevant code:
mPicasso.load(url).placeholder(R.drawable.bird_placeholder).error(R.drawable
.bird_placeholder).into(holder.photo);
holder.photo is a SquaredImageView, meaning it has the same width and height. And the scaleType is "centerCrop".
The text was updated successfully, but these errors were encountered: