-
Notifications
You must be signed in to change notification settings - Fork 2
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.
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: ...
Icon Type: Notification Icons Asset Type: ... Trim: ( ) Yes (.) No Padding: 0%
If you would like a custom color, it’s a pain!
-
Grab an SVG file with 24x24 size (for example from Material design icons).
-
Change the color in the SVG file.
-
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
-
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
Copyright © 2017-2023 Dario Scoppelletti, http://www.scoppelletti.it