title: How to have a selector of vector drawables?
body: <h2>Background</h2>
  
  <p>I've made the following ImageView, to support selectors as "src" :</p>
  
  <pre><code>public class CheckableImageView extends ImageView implements Checkable {
      private boolean mChecked;
  
      private static final int[] CHECKED_STATE_SET = { android.R.attr.state_checked };
  
      public CheckableImageView(final Context context, final AttributeSet attrs) {
          super(context, attrs);
          final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.com_app_CheckableImageView, 0, 0);
          setChecked(a.getBoolean(R.styleable.com_app_CheckableImageView_com_app_checked, false));
          a.recycle();
      }
  
      @Override
      public int[] onCreateDrawableState(final int extraSpace) {
          final int[] drawableState = super.onCreateDrawableState(extraSpace + 1);
          if (isChecked())
              mergeDrawableStates(drawableState, CHECKED_STATE_SET);
          return drawableState;
      }
  
      @Override
      public void toggle() {
          setChecked(!mChecked);
      }
  
      @Override
      public boolean isChecked() {
          return mChecked;
      }
  
      public interface OnCheckStateListener {
          void onCheckStateChanged(boolean checked);
      }
  
      private OnCheckStateListener mOnCheckStateListener;
  
      public void setOnCheckStateListener(OnCheckStateListener onCheckStateListener) {
          mOnCheckStateListener = onCheckStateListener;
      }
  
      @Override
      public void setChecked(final boolean checked) {
          if (mChecked == checked)
              return;
          mChecked = checked;
          refreshDrawableState();
          if (mOnCheckStateListener != null) 
              mOnCheckStateListener.onCheckStateChanged(checked);
      }
  }
  </code></pre>
  
  <h2>The problem</h2>
  
  <p>The above code works fine with normal selectors, that have image files as items drawable for each state.</p>
  
  <p>Thing is, it doesn't work at all with vector drawables (using "srcCompat"). Instead, it shows an empty content.</p>
  
  <p>Here's what I tried:</p>
  
  <pre><code>        &lt;...CheckableImageView
           ...
              app:srcCompat="@drawable/selector"/&gt;
  </code></pre>
  
  <p>And the selector (for example) is :</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;selector xmlns:android="http://schemas.android.com/apk/res/android"&gt;
      &lt;item  android:state_checked="true" android:drawable="@drawable/test"/&gt;
      &lt;item  android:state_pressed="true" android:drawable="@drawable/test" /&gt;
      &lt;item android:drawable="@drawable/test2" /&gt;
  &lt;/selector&gt;
  </code></pre>
  
  <p>example vector drawable:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;vector xmlns:android="http://schemas.android.com/apk/res/android"
          android:width="48dp"
          android:height="48dp"
          android:viewportWidth="48"
          android:viewportHeight="48"&gt;
  
      &lt;path
          android:fillColor="#0000ff"
          android:strokeColor="#000000"
          android:pathData="M 0 0 H 48 V 48 H 0 V 0 Z" /&gt;
  
      &lt;path
          android:fillColor="#ff0000"
          android:strokeColor="#000000"
          android:pathData="M14.769224,32.692291l5.707315,-17.692275l3.073244,17.479182l6.585245,-16.413424l2.634209,16.200186l-4.170761,-8.526356l-5.048693,7.247362l-5.268419,-8.100027l-3.51214,9.805351z" /&gt;
  &lt;/vector&gt;
  </code></pre>
  
  <h2>The question</h2>
  
  <p>Why doesn't it work? What's wrong with what I did? How can I fix it?</p>