Skip to content

Vector Drawables compatibility

Dario Scoppelletti edited this page Sep 14, 2020 · 2 revisions

Support Library supports Vector Drawables, but, if API level < 21, the following attributes are not covered:

  • Background

  • Compound drawables

  • Selectors

  • Layer lists

  • Preference icons

  • …​

In such cases, you have to insert in your Android Studio project an Image Asset.

Action Bar and Tab Icons

Icon Type: Action Bar and Tab Icons
Name: ...
Asset Type: ...
Trim: ( ) Yes (.) No
Padding: 0%
Theme: HOLO_LIGHT

or

Icon Type: Action Bar and Tab Icons
Name: ...
Asset Type: ...
Trim: ( ) Yes (.) No
Padding: 0%
Theme: CUSTOM
Custom color: ...

Notification Icons

Icon Type: Notification Icons
Asset Type: ...
Trim: ( ) Yes (.) No
Padding: 0%

Custom color

If you would like a custom color, it’s a pain!

  1. Grab an SVG file with 24x24 size (for example from Material design icons).

  2. Change the color in the SVG file.

  3. Convert the SVG file in a PNG image asset, for example using Inkscape:

    $ inkscape -o drawable-mdpi/ic_name.png -w 24 -h 24 ic_name.svg
    $ inkscape -o drawable-hdpi/ic_name.png -w 36 -h 36 ic_name.svg
    $ inkscape -o drawable-xhdpi/ic_name.png -w 48 -h 48 ic_name.svg
    $ inkscape -o drawable-xxhdpi/ic_name.png -w 72 -h 72 ic_name.svg
  4. I am confused regarding the need of a particular DPI of the images, however, if you want to set your images to 72 DPI, you can use, for example, ImageMagick:

    $ convert -units PixelsPerInch input.png -density 72 output.png
Clone this wiki locally