Android working with SVG / vector drawables
While developing Android Applications, supporting multiple resolutions are sometime nightmare to developers. Including multiple images for different resolutions also increases the project size. The solution is to use Vector Graphics such as SVG images. While Android does not support SVGs (Scalable Vector Graphics) directly, with the launch of Lollipop a new class was introduced called VectorDrawable, which allows designers and developers to draw assets in a similar fashion using only code.
Simply explained, vector graphics are a way of describing graphical elements using geometric shapes. They are particularly well suited to graphical elements created in packages such as Adobe Illustrator or Inkscape. where simple geometric shapes may be combined in to much more complex elements.
Adding config to gradle file
Add following new attribute
[// Gradle Plugin 2.0+
android {
defaultConfig {
vectorDrawables.useSupportLibrary = true
}
}]
Import Vector Assets to Android Studio
Once you import vector assets, you can now use app:srcCompat instead of android:src to render images
And thats it. Enjoy
Android working with SVG / vector drawables
Reviewed by sahar ali raza
on
August 09, 2017
Rating: 5
![Android working with SVG / vector drawables](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgI1L3dPqQd6YhrKw6gf77C8abeqibxMNrcBI0qNhse2ElCMXfIlPtJQAGZcXs_1PqQi-f-fyAOIC7NBo4XEjxoKhfj9YKGb-ydArOfedX7g1N4Niqabx8FRvfrXc17uvxSoLa2H-E6BAs/s72-c/Android+working+with+SVG.jpg)