I have a svg
created in an HTML page.
For example, for simplicity, we can take this simple example:
<svg>
<circle r="60px" fill="red" cx="90" cy="65"></circle>
</svg>
And I would like to be able to use it on Android. I have seen that what can be done for this is to create a file svg
and import it, however, I do not know how to create that file and in most places they tell me how to export an image to a file svg
(that is, a conversion) but I I want to insert in a file svg
the svg
one I show in the previous example.
Therefore, I have a couple of questions:
Does a file
svg
have to have a particular structure? AsHTML
it has the following structure:<html><head></head><body></body></html>
If it does not have any particular structure, would it be entered
svg
as it is in the previous example? That is, would the be enteredsvg
with the same tags as in the HTML?
Thank you very much.
You can try with the following code:
The version can be 1.0, 1.1 or 1.2 (everything will depend on the properties of each element, if they are supported or not by the version you use). Also, 'baseProfile' is telling you to use the basic (which android surely supports). To start you have Mozilla Tutorial .
Create .SVG file
Base structure of an icon file
.svg
modify<path...
it with the stroke of the icon you wantImport .SVG file
To use a
svg
in an Android project, you must convert it tovector drawables
for that, you place yourself above the directoryDrawables
inAndroid-Studio
open the context menu and selectNew->Vector Asset
A dialog box will open, where you can upload your custom svg:
Choose
Local Files
24x24
yes for button icons, you can always resize it directly withwidth
yheight
of the component.Official Documentation Create drawable interfaces in vector
Modify its color
To change the color, once passed the
.svg
avector-drawable
in your .xml inside the directorydrawable
you can specifyfillColor
with valueARGB
.The files
svg
do not have a fixed structure. Being a labeling file when there is no marked label, they take a default data.As many forms as necessary can be added, taking care that the identifiers do not coincide and create ambiguities.
NOTE: If you want to combine several different elements,
svg
you must be careful not to have unexpected results (for example, if one element has a size marked that, compared to the size marked by the other, there is a huge difference that makes practically missing one, or giving overlapping default values)