private void updateAttrs(Drawable drawable) {
    if (drawable == null) {
      return;
    }

    if (drawable instanceof RoundedDrawable) {
      ((RoundedDrawable) drawable)
          .setScaleType(mScaleType)
          .setBorderWidth(mBorderWidth)
          .setBorderColor(mBorderColor)
          .setOval(mIsOval)
          .setTileModeX(mTileModeX)
          .setTileModeY(mTileModeY);

      if (mCornerRadii != null) {
        ((RoundedDrawable) drawable)
            .setCornerRadius(
                mCornerRadii[CORNER_TOP_LEFT],
                mCornerRadii[CORNER_TOP_RIGHT],
                mCornerRadii[CORNER_BOTTOM_RIGHT],
                mCornerRadii[CORNER_BOTTOM_LEFT]);
      }

      applyColorMod();
    } else if (drawable instanceof LayerDrawable) {
      // loop through layers to and set drawable attrs
      LayerDrawable ld = ((LayerDrawable) drawable);
      for (int i = 0, layers = ld.getNumberOfLayers(); i < layers; i++) {
        updateAttrs(ld.getDrawable(i));
      }
    }
  }
 @Override
 public void setColorFilter(ColorFilter cf) {
   if (mColorFilter != cf) {
     mColorFilter = cf;
     mHasColorFilter = true;
     mColorMod = true;
     applyColorMod();
     invalidate();
   }
 }