Android Studio Vector Drawable tool
npm install vd-toolPackaging of the Android Studio VectorDrawable CLI tool
- Requires Java 8 or higher
Binaries were built using the following branch:
``bash
$ npm install -g vd-tool
$ vd-tool
Converts SVG files to VectorDrawable XML files.
Displays VectorDrawables.
Usage: [-c] [-d] [-in
Options:
-in
to VectorDrawable XML, or if a directory is specified,
all .svg files in the given directory. Otherwise, if -d
is specified, displays the given VectorDrawable XML file
or all VectorDrawables in the given directory.
-out
directory, which must exist. If not specified the
converted files will be written to the directory
containing the input files.
-c If present, SVG files are converted to VectorDrawable XML
and written out.
-d Displays the given VectorDrawable(s), or if -c is
specified the results of the conversion.
-widthDp
-heightDp
-addHeader Add AOSP header to the top of the generated XML file
Examples:
1) Convert SVG files from
vd-tool -c -d -in
2) Convert SVG file and visualize the XML file results:
vd-tool -c -d -in file.svg
3) Display VectorDrawable's XML files from
vd-tool -d -in
`
`bash`
$ npm i vd-tool
`javascript
const { vdConvert } = require('vd-tool')
vdConvert('path/to/svg-file-or-dir', options: {
outDir?: string // output dir path
width?: number // forces width in DP
height?: number // forces height in DP
addHeader?: boolean // add AOSP header
})
.then(() => {
//...
})
.catch(({message}) => {
console.error('message')
})
``