SVG image has 6 icons and you need to choose one?

I have an SVG file format that has a 5-6 icon in it, and I need to select the icon according to the requirement of not the whole image.

In just you can parse .SVG on your ImageView or Canvas, but this time I need to select a specific icon from a number.

Is it possible to do this with encoding or do I need to draw all the icons separately?

enter image description here

Can someone tell me how to do this?

0
source share
3 answers

I have not tried, but you can:

  • Create a bitmap with the size of your icon
  • Create a new canvas associated with this bitmap
  • Draw your svg on the canvas with offset - If your icon coordinates are (X1, Y1) - Then when you draw the substract SVG element (X1, Y1)
  • Draw a bitmap on the screen.

This is a bit of a do-it-yourself solution ... maybe there are some libraries that make this king of things for you.

0
source

You can set the clip and broadcast on the canvas before drawing to hide everything except the icon you need, but I think the best way to do this is to use separate image files.

0
source

You do not say which SVG library you are using. If you use AndroidSVG, you can add <view> elements to your SVG (one for each icon) and select the appropriate icon for drawing using renderViewToPicture (), etc.

0
source

Source: https://habr.com/ru/post/1501296/


All Articles