Vector drawable’s saves size of the application. Android uses single version of the SVG (Scalable Vector Graphics) XML image and makes it adjustable to all the resolutions of phone.
The advantages of Vector drawable’s are,
- No need to maintain different resolution of images in multiple resolution folders like LDPI, MDPI, HDPI & XHDPI.
- keep single svg xml format image in Drawable folder & start using it.
Android app-compat support Library 23.2.0 supports vectordrawable from API 7 onwards. Here are the steps to use it in Application.
- Convert PNG, JPEG, GIF etc… multiple image format to SVG. Just use image converter tool.
- Convert SVG image to Android vectordrawable, use svg2android tool & generate XML.
- Copy the generated XML file and put it in drawable folder of application.
- Start using it in application.
<ImageView android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_centerInParent="true" android:src="@drawable/apple"/> <!-- Vector drawable -->
Gradle file changes:
In order to get better support of SVG from API 7, its good to upgrade Android studio 2.0. The gradle V2.0 is also available by default.
In App Gradle file, update support lib dependency as com.android.support:appcompat-v7:23.3.0.
Run application in different resolutions of phones or emulator.