How to add Vector image support to old Android versions using new AppCompat?

Standard

Finally we had vector support for all Android versions, 8-)

  • bye bye all different PNG size files in different drawable folders!
  • bye bye FontAwesome!
  1. first of all add these dependencies to your module’s build.gradle:
dependencies {
    .
    .
    .
    compile 'com.android.support:appcompat-v7:23.3.0'
    compile 'com.android.support:support-vector-drawable:23.3.0'
  1. add this to your android defaultConfig tag in your module’s build.gradle:
android {
    .
    .
    .

    defaultConfig {
        .
        .
        .
        vectorDrawables.useSupportLibrary = true
    }
  1. replace all your ImageView with android.support.v7.widget.AppCompatImageView
    and ImageButton with android.support.v7.widget.AppCompatImageButton in all your project’s xml layouts.

  2. replace all android:src attribute in all ImageView with app:srcCompat.

  3. now import your vector image using New -> “Vector Asset” submenu by right clicking on your drawable folder…

That’s it!!!

Leave a Reply

Your email address will not be published. Required fields are marked *