Alterar dinamicamente a cor da imagem SVG no Android
Eu sei que usando a biblioteca de terceiros, é possível usar a imagem SVG no Android. Biblioteca como:svg-android
O código para carregar a imagem SVG é como abaixo:
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);
}
Está funcionando bem. Eu consigo ver a imagem. Mas agora eu quero mudar a cor da imagem svg em tempo de execução. Para isso, tentei o código abaixo, conforme mencionado na mesma descrição do projeto.
// 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);
Mas com isso eu não sou capaz de ver a mudança na cor. Então, eu gostaria de saber como é possível alterar a cor dinamicamente no arquivo Java.