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

会有一股神秘感。 提交于 2019-12-20 06:09:37

问题


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 your ImageView Or Canvas but this time I need to choose particular icon from the among.

Is this possible to do with the coding or i need to draw all icon separately ?

Somebody suggest me the way, how to make it happen ?


回答1:


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.




回答2:


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.




回答3:


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.



来源:https://stackoverflow.com/questions/18713383/a-svg-image-have-6-icon-and-need-to-choose-one

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!