Cambiar dinámicamente el color de la imagen SVG en Android
Sé que usando una biblioteca de terceros, es posible usar una imagen SVG en Android. Biblioteca como:svg-android
El código para cargar la imagen SVG es el siguiente:
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Create a new ImageView
ImageView imageView = new ImageView(this);
// Set the background color to white
imageView.setBackgroundColor(Color.WHITE);
// Parse the SVG file from the resource
SVG svg = SVGParser.getSVGFromResource(getResources(), R.raw.android);
// Get a drawable from the parsed SVG and set it as the drawable for the ImageView
imageView.setImageDrawable(svg.createPictureDrawable());
// Set the ImageView as the content view for the Activity
setContentView(imageView);
}
Funciona bien Puedo ver la imagen. Pero ahora quiero cambiar el color de la imagen svg en tiempo de ejecución. Para eso probé el siguiente código como se menciona en la misma descripción del proyecto.
// 0xFF9FBF3B is the hex code for the existing Android green, 0xFF1756c9 is the new blue color
SVG svg = SVGParser.getSVGFromResource(getResources(), R.raw.android, 0xFF9FBF3B, 0xFF1756c9);
Pero con eso no puedo ver el cambio en el color. Por lo tanto, me gustaría saber cómo es posible cambiar el color dinámicamente en un archivo Java.