Android dynamically changes the color of SVG
When an SVG file references the project’s birthday xxx.xml file
In this case, we use imageView as the carrier. Change the color to red in the code and default to white.
Drawable drawable = imageView.getDrawable();
drawable.setTint(getResources().getColor(R.color.red));
Copy the code
When this resource is used in other scenarios. The resource is also found to be red in color.
why
The resource is loaded into memory. When a resource is modified, it is actually a resource that modifies memory. The resource memory is not overwritten or reclaimed at this time. When used again, the state of our last modification is preserved.