I have a png file loaded in image view in the layout. Then I have a svg image which I need to render on top of that png image.
Please suggest any possible ways.
And let me know if you have any clarifications on my question.
SVG svg1 = SVGParser.getSVGFromResource(getResources(), R.raw.svg_image1);
Drawable resID1 = svg1.createPictureDrawable();
SVG svg2 = SVGParser.getSVGFromResource(getResources(), R.raw.svg_image2);
Drawable resID2 = svg2.createPictureDrawable();
SVG svg3 = SVGParser.getSVGFromResource(getResources(), R.raw.svg_image3);
Drawable resID3 = svg3.createPictureDrawable();
Drawable mainImage = this.getResources().getDrawable(R.drawable.main_image);
LayerDrawable ld = new LayerDrawable(new Drawable[]{mainImage, resID1, resID2, resID3});
ld.setLayerInset(1, 1, 1, 1, 1);
ImageView imageView = (ImageView) findViewById(R.id.img1);
imageView.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
imageView.setImageDrawable(ld);
There are several ways to achieve what you want.
You could use a FrameLayout to stack an ImageView and an SVGImageView.
You could read your PNG into a Bitmap. Then use that Bitmap to create a Canvas. Then pass that Canvas to SVG.renderToCanvas();
Plus several others I can think of. Your question is a bit broad. The best solution will depend on other factors, such as what you want to do once it is rendered. Is it going to be interactive? Updated and redrawn? etc.