Vector drawable

A VectorDrawable is a vector graphic defined in an XML file as a set of points, lines, and curves along with its associated color information. It has following advantages:

  • it can be scaled without loss of display quality
  • smaller APK files and less developer maintenance

To optimize for the re-drawing performance, one bitmap cache is created for each VectorDrawable.

VectorDrawable class represents a static vector image.

There are also AnimatedVectorDrawable resource and class, that represent animated vector image.

The Vector Asset tool in Android Studio allows you to draw an image, import an svg file, or select one of the predefined images.

File -> New -> Vector Asset

Similar to the SVG format, each vector graphic is defined as a tree hierachy, which is made up of path and group objects. Each path contains the geometry of the object's outline and group contains details for transformation.

Vector xml example

To support day/night theme add android:tint attribute, and don't change content of image.

<vector xmlns:android="http://schemas.android.com/apk/res/android"
    android:width="24dp"
    android:height="24dp"
    android:tint="?android:colorControlNormal"
    android:viewportWidth="24"
    android:viewportHeight="24">
 ...
</vector>