A SVG Image have 6 icon and need to choose one?

后端 未结 3 677
余生分开走
余生分开走 2021-01-27 16:44

I have an SVG file format in which there is 5-6 icon and I need to pick icon according to the requirement not the whole Image.

In Simply you can parse the .SVG onto you

相关标签:
3条回答
  • 2021-01-27 17:16

    You could set a clip and translation on the canvas before drawing to hide all but the icon you want, but I think the best course of action is to use separate image files.

    0 讨论(0)
  • 2021-01-27 17:19

    I did not try it but you may :

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

    It is a little bit homemade solution... maybe there is some libraries doing those king of things for you.

    0 讨论(0)
  • 2021-01-27 17:19

    You don't say which SVG library you are using. If you are using AndroidSVG, you could add <view> elements to your SVG (one for each icon) and select the appropriate icon to draw using renderViewToPicture() etc.

    0 讨论(0)
提交回复
热议问题