Skip to content
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

[Coil 3] make crossfade support using different scale type for placeholder vs final image #2277

Closed
nift4 opened this issue May 20, 2024 · 3 comments · Fixed by #2280
Closed
Labels
enhancement New feature or request

Comments

@nift4
Copy link

nift4 commented May 20, 2024

Is your feature request related to a problem? Please describe.
My placeholder is a vector drawable and can adjust to bounds itself properly. In a RecyclerView where all ImageViews have same bounds but final images are different resolution, the placeholder, which is rendered in final image's resolution when using crossfade (because well, CrossfadeDrawable does need some bounds and cannot just change them during the animation - but this in itself is not a problem for me as my placeholder is a vector drawable) will then be cropped if I set Scale.FILL in ImageRequest builder. I do want to crop my final image, but my placeholder should use Scale.FIT instead.

Describe the solution you'd like
Simple API where I can set scale type for placeholder to avoid it being cropped.

Additional context
I can work around this missing feature by copy pasting around 500 lines from coil3 into my project and setting a custom transition factory which has a very hacky workaround for this - but it's very annoying.
Thanks for the great library, other than this one I encountered no issues :D

@nift4 nift4 added the enhancement New feature or request label May 20, 2024
@colinrtwhite
Copy link
Member

@nift4 Does wrapping your placeholder in a ScaleDrawable solve this issue? I'd prefer to avoid adding a new API for this as it's an uncommon use case and it's possible to implement this with one of Coil's existing extension points (Transition, Interceptor, Listener, etc.).

@nift4
Copy link
Author

nift4 commented May 20, 2024

That works and is a lot cleaner, thanks :) any chance to get this moved out of gif into another package?

@colinrtwhite
Copy link
Member

Yep, I think it's fair to move it if we're recommending it for this use case. It's a small class and R8 will easily strip it if it's unused.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants