Ejemplo n.º 1
0
  public void setCornerRadius(int radius) {
    if (mCornerRadius == radius) {
      return;
    }

    mCornerRadius = radius;
    if (mDrawable instanceof RoundedDrawable) {
      ((RoundedDrawable) mDrawable).setCornerRadius(radius);
    }
    if (mRoundBackground && mBackgroundDrawable instanceof RoundedDrawable) {
      ((RoundedDrawable) mBackgroundDrawable).setCornerRadius(radius);
    }
  }
Ejemplo n.º 2
0
 private void updateDrawableAttrs(RoundedDrawable drawable) {
   drawable.setScaleType(mScaleType);
   drawable.setCornerRadius(mCornerRadius);
   drawable.setBorderWidth(mBorderWidth);
   drawable.setBorderColors(mBorderColor);
   drawable.setOval(mOval);
 }
Ejemplo n.º 3
0
  private void updateAttrs(Drawable drawable) {
    if (drawable == null) {
      return;
    }

    if (drawable instanceof RoundedDrawable) {
      ((RoundedDrawable) drawable).setScaleType(mScaleType);
      ((RoundedDrawable) drawable).setCornerRadius(mCornerRadius);

      mDrawable.setColorFilter(mColorFilter);
    } 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));
      }
    }
  }
Ejemplo n.º 4
0
  public void setRoundBackground(boolean roundBackground) {
    if (mRoundBackground == roundBackground) {
      return;
    }

    mRoundBackground = roundBackground;
    if (roundBackground) {
      if (mBackgroundDrawable instanceof RoundedDrawable) {
        updateDrawableAttrs((RoundedDrawable) mBackgroundDrawable);
      } else {
        setBackgroundDrawable(mBackgroundDrawable);
      }
    } else if (mBackgroundDrawable instanceof RoundedDrawable) {
      ((RoundedDrawable) mBackgroundDrawable).setBorderWidth(0);
      ((RoundedDrawable) mBackgroundDrawable).setCornerRadius(0);
    }

    invalidate();
  }