0

I am using vector drawables all around the place in my app. Today I tested with a JellyBean device and they are all ignoring the color I defined in my XML.

This is an example of a Vector Drawable Im using:

<?xml version="1.0" encoding="utf-8"?>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
        android:height="24dp"
        android:width="24dp"
        android:viewportWidth="24"
        android:viewportHeight="24">
    <path android:fillColor="@color/colorWhite" android:pathData="M17,10.5V7A1,1 0 0,0 16,6H4A1,1 0 0,0 3,7V17A1,1 0 0,0 4,18H16A1,1 0 0,0 17,17V13.5L21,17.5V6.5L17,10.5Z" />
</vector>

And this is how they show up:

Jellybean:

JellyBean

MarshMallow:

MarshMallow

MichelReap
  • 5,630
  • 11
  • 37
  • 99

1 Answers1

1

See for backward compatibility, you need to add this to your gradle,

// Gradle Plugin 2.0+
 android {
   defaultConfig {
     vectorDrawables.useSupportLibrary = true
    }
 }

then you'd be able to use the reference method. This is to make the support library compatible with older versions.

This thread here, explains how to use the same in all android versions and this one here explains the rest.

Regards.

Q2x13
  • 534
  • 1
  • 4
  • 14