title: TypedArray .getColor() always returning -1 in custom view
body: <p>I've created a custom view which subclasses <code>TextView</code> called <code>TextViewEx</code>.  This view simply adds more flexibility over the compound <code>Drawables</code> available to <code>TextView</code> via the xml.  Part of the functionality I'd like to as is the ability to tint the compound drawables, but for whatever reason the color returned is always <code>-1</code>.  Here's the code:</p>
  
  <p>attrs.xml:</p>
  
  <pre><code>&lt;resources&gt;
      &lt;declare-styleable name="TextViewEx"&gt;
          &lt;attr name="drawableLeftWidth" format="dimension" /&gt;
          &lt;attr name="drawableLeftHeight" format="dimension" /&gt;
          &lt;attr name="drawableLeftTint" format="color" /&gt;
  
          &lt;attr name="drawableTopWidth" format="dimension" /&gt;
          &lt;attr name="drawableTopHeight" format="dimension" /&gt;
          &lt;attr name="drawableTopTint" format="color" /&gt;
  
          &lt;attr name="drawableRightWidth" format="dimension" /&gt;
          &lt;attr name="drawableRightHeight" format="dimension" /&gt;
          &lt;attr name="drawableRightTint" format="color" /&gt;
  
          &lt;attr name="drawableBottomWidth" format="dimension" /&gt;
          &lt;attr name="drawableBottomHeight" format="dimension" /&gt;
          &lt;attr name="drawableBottomTint" format="color" /&gt;
      &lt;/declare-styleable&gt;
  &lt;/resources&gt;
  </code></pre>
  
  <p>TextViewEx.java:</p>
  
  <pre><code>public class TextViewEx
          extends TextView {
  
      public TextViewEx(Context context) {
          super(context);
          init(null, 0);
      }
  
      public TextViewEx(Context context, AttributeSet attrs) {
          super(context, attrs);
          init(attrs, 0);
      }
  
      public TextViewEx(Context context, AttributeSet attrs, int defStyle) {
          super(context, attrs, defStyle);
          init(attrs, defStyle);
      }
  
      private void init(AttributeSet attrs, int defStyle) {
  
          if (attrs==null) {
              return;
          }
  
          TypedArray a = getContext().obtainStyledAttributes(
                  attrs, R.styleable.TextViewEx, defStyle, 0);
  
          int lTint = -1, lWidth = -1, lHeight = -1;
          int tTint = -1, tWidth = -1, tHeight = -1;
          int rTint = -1, rWidth = -1, rHeight = -1;
          int bTint = -1, bWidth = -1, bHeight = -1;
  
          try {
              lTint = a.getColor(R.styleable.TextViewEx_drawableLeftTint, getCurrentTextColor());
              lWidth = a.getDimensionPixelSize(R.styleable.TextViewEx_drawableLeftWidth, 0);
              lHeight = a.getDimensionPixelSize(R.styleable.TextViewEx_drawableLeftHeight, 0);
  
              tTint = a.getColor(R.styleable.TextViewEx_drawableTopTint, getCurrentTextColor());
              tWidth = a.getDimensionPixelSize(R.styleable.TextViewEx_drawableTopWidth, 0);
              tHeight = a.getDimensionPixelSize(R.styleable.TextViewEx_drawableTopHeight, 0);
  
              rTint = a.getColor(R.styleable.TextViewEx_drawableRightTint, getCurrentTextColor());
              rWidth = a.getDimensionPixelSize(R.styleable.TextViewEx_drawableRightWidth, 0);
              rHeight = a.getDimensionPixelSize(R.styleable.TextViewEx_drawableRightHeight, 0);
  
              bTint = a.getColor(R.styleable.TextViewEx_drawableBottomTint, getCurrentTextColor());
              bWidth = a.getDimensionPixelSize(R.styleable.TextViewEx_drawableBottomWidth, 0);
              bHeight = a.getDimensionPixelSize(R.styleable.TextViewEx_drawableBottomHeight, 0);
          } finally {
              a.recycle();
          }
  
          Drawable[] drawables = getCompoundDrawables();
          if (drawables[0]!=null &amp;&amp; lWidth!=0 &amp;&amp; lHeight!=0) {
              drawables[0].setBounds(0, 0, lWidth, lHeight);
          }
          if (drawables[1]!=null &amp;&amp; tWidth!=0 &amp;&amp; tHeight!=0) {
              drawables[1].setBounds(0, 0, tWidth, tHeight);
          }
          if (drawables[2]!=null &amp;&amp; rWidth!=0 &amp;&amp; rHeight!=0) {
              drawables[2].setBounds(0, 0, rWidth, rHeight);
          }
          if (drawables[3]!=null &amp;&amp; bWidth!=0 &amp;&amp; bHeight!=0) {
              drawables[3].setBounds(0, 0, bWidth, bHeight);
          }
  
          if (drawables[0]!=null &amp;&amp; lTint!=-1) {
              Graphics.tint(drawables[0], lTint);
          }
          if (drawables[1]!=null &amp;&amp; tTint!=-1) {
              Graphics.tint(drawables[1], tTint);
          }
          if (drawables[2]!=null &amp;&amp; rTint!=-1) {
              Graphics.tint(drawables[2], rTint);
          }
          if (drawables[3]!=null &amp;&amp; bTint!=-1) {
              Graphics.tint(drawables[3], bTint);
          }
  
          setCompoundDrawables(drawables[0], drawables[1], drawables[2], drawables[3]);
  
      }
  }
  </code></pre>
  
  <p>and in use:</p>
  
  <pre><code>    &lt;com.cheerfulinc.flipagram.view.TextViewEx
          android:id="@+id/likesCount"
          android:gravity="center_vertical"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_alignParentBottom="true"
          android:layout_marginLeft="30dp"
          android:layout_marginBottom="30dp"
          android:background="@drawable/red_pill_text"
          android:textColor="@android:color/white"
          android:text="22,4456"
          android:drawableRight="@drawable/fg_icon_heart"
          android:drawablePadding="6dp"
          app:drawableRightWidth="12dp"
          app:drawableRightHeight="12dp"
          app:drawableRightTint="#FFFFFFFF" /&gt;
  </code></pre>
  
  <p>I've also tried doing: <code>app:drawableRightTint="@android:color/white"</code> but no mater what, the color value returned is always <code>-1</code></p>