Methods Summary |
---|
public void | applyTheme(android.content.res.Resources.Theme t)
super.applyTheme(t);
final ColorState state = mColorState;
if (state == null || state.mThemeAttrs == null) {
return;
}
final TypedArray a = t.resolveAttributes(state.mThemeAttrs, R.styleable.ColorDrawable);
updateStateFromTypedArray(a);
a.recycle();
|
public boolean | canApplyTheme()
return mColorState.canApplyTheme() || super.canApplyTheme();
|
public void | clearMutated()
super.clearMutated();
mMutated = false;
|
public void | draw(Canvas canvas)
final ColorFilter colorFilter = mPaint.getColorFilter();
if ((mColorState.mUseColor >>> 24) != 0 || colorFilter != null || mTintFilter != null) {
if (colorFilter == null) {
mPaint.setColorFilter(mTintFilter);
}
mPaint.setColor(mColorState.mUseColor);
canvas.drawRect(getBounds(), mPaint);
// Restore original color filter.
mPaint.setColorFilter(colorFilter);
}
|
public int | getAlpha()Returns the alpha value of this drawable's color.
return mColorState.mUseColor >>> 24;
|
public int | getChangingConfigurations()
return super.getChangingConfigurations() | mColorState.mChangingConfigurations;
|
public int | getColor()Gets the drawable's color value.
return mColorState.mUseColor;
|
public ConstantState | getConstantState()
return mColorState;
|
public int | getOpacity()
if (mTintFilter != null || mPaint.getColorFilter() != null) {
return PixelFormat.TRANSLUCENT;
}
switch (mColorState.mUseColor >>> 24) {
case 255:
return PixelFormat.OPAQUE;
case 0:
return PixelFormat.TRANSPARENT;
}
return PixelFormat.TRANSLUCENT;
|
public void | getOutline(Outline outline)
outline.setRect(getBounds());
outline.setAlpha(getAlpha() / 255.0f);
|
public void | inflate(android.content.res.Resources r, org.xmlpull.v1.XmlPullParser parser, android.util.AttributeSet attrs, android.content.res.Resources.Theme theme)
super.inflate(r, parser, attrs, theme);
final TypedArray a = obtainAttributes(r, theme, attrs, R.styleable.ColorDrawable);
updateStateFromTypedArray(a);
a.recycle();
|
public boolean | isStateful()
return mColorState.mTint != null && mColorState.mTint.isStateful();
|
public Drawable | mutate()A mutable BitmapDrawable still shares its Bitmap with any other Drawable
that comes from the same resource.
if (!mMutated && super.mutate() == this) {
mColorState = new ColorState(mColorState);
mMutated = true;
}
return this;
|
protected boolean | onStateChange(int[] stateSet)
final ColorState state = mColorState;
if (state.mTint != null && state.mTintMode != null) {
mTintFilter = updateTintFilter(mTintFilter, state.mTint, state.mTintMode);
return true;
}
return false;
|
public void | setAlpha(int alpha)Sets the color's alpha value.
alpha += alpha >> 7; // make it 0..256
final int baseAlpha = mColorState.mBaseColor >>> 24;
final int useAlpha = baseAlpha * alpha >> 8;
final int useColor = (mColorState.mBaseColor << 8 >>> 8) | (useAlpha << 24);
if (mColorState.mUseColor != useColor) {
mColorState.mUseColor = useColor;
invalidateSelf();
}
|
public void | setColor(int color)Sets the drawable's color value. This action will clobber the results of
prior calls to {@link #setAlpha(int)} on this object, which side-affected
the underlying color.
if (mColorState.mBaseColor != color || mColorState.mUseColor != color) {
mColorState.mBaseColor = mColorState.mUseColor = color;
invalidateSelf();
}
|
public void | setColorFilter(ColorFilter colorFilter)Sets the color filter applied to this color.
Only supported on version {@link android.os.Build.VERSION_CODES#LOLLIPOP} and
above. Calling this method has no effect on earlier versions.
mPaint.setColorFilter(colorFilter);
|
public void | setTintList(android.content.res.ColorStateList tint)
mColorState.mTint = tint;
mTintFilter = updateTintFilter(mTintFilter, tint, mColorState.mTintMode);
invalidateSelf();
|
public void | setTintMode(android.graphics.PorterDuff.Mode tintMode)
mColorState.mTintMode = tintMode;
mTintFilter = updateTintFilter(mTintFilter, mColorState.mTint, tintMode);
invalidateSelf();
|
private void | updateStateFromTypedArray(android.content.res.TypedArray a)Updates the constant state from the values in the typed array.
final ColorState state = mColorState;
// Account for any configuration changes.
state.mChangingConfigurations |= a.getChangingConfigurations();
// Extract the theme attributes, if any.
state.mThemeAttrs = a.extractThemeAttrs();
state.mBaseColor = a.getColor(R.styleable.ColorDrawable_color, state.mBaseColor);
state.mUseColor = state.mBaseColor;
|