fix(android): reapply tintColor when Image src changes#11145
fix(android): reapply tintColor when Image src changes#11145owenthcarey wants to merge 1 commit intoNativeScript:mainfrom
Conversation
|
View your CI Pipeline Execution ↗ for commit 09312a7
☁️ Nx Cloud last updated this comment at |
|
@owenthcarey Thanks for the PR! I tried to replicate your problem but I couldn't. The tint-color is applied using css: #img {
tint-color: red;
}screen-20260327-190404.mp4Also, regarding the following statement: The ImageView class handles the color filter internally, so it should normally be persisted between bitmap changes. Could you please create an issue related to the problem and post an app sample or a recording demonstrating the problem from your device? Maybe it could be a corner case we're unaware of. |
CatchABus
left a comment
There was a problem hiding this comment.
Awaiting response from the author.
|
I believe this case is with dynamic bindings, not css @CatchABus - if the toolbox image-handling is run with the index.android changes commented out the issue shows itself. |
Thanks for pointing this out @NathanWalker. I'll check it out and continue with the review. |
|
This appears to be unique to Angular binding case, not directly represented in core (xml). We'll leave open until more clarity emerges. |
On Android, ColorFilter is applied to the Drawable, not the ImageView itself. When src changes dynamically (e.g. via binding), the new drawable replaces the old one and the tint is lost. This differs from iOS, where tintColor is a view-level property that persists across image changes.
This adds
_reapplyTintColor()to the Android Image implementation and calls it from both code paths that load a new image:onImageLoaded-- for images loaded natively via setUri (file/resource paths)[imageSourceProperty.setNative]-- for images set viasetImageBitmap(font icons, data URIs, ImageSource/ImageAsset)