Class ColorDrawable
java.lang.Object
icyllis.modernui.graphics.drawable.Drawable
icyllis.modernui.graphics.drawable.ColorDrawable
A specialized Drawable that fills the Canvas with a specified color.
-
Nested Class Summary
Nested classes/interfaces inherited from class icyllis.modernui.graphics.drawable.Drawable
Drawable.Callback, Drawable.ConstantState
-
Field Summary
-
Constructor Summary
ConstructorDescriptionCreates a new black ColorDrawable.ColorDrawable
(int color) Creates a new ColorDrawable with the specified color. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Clears the mutated state, allowing this drawable to be cached and mutated again.void
Draw in its bounds (set via setBounds) respecting optional effects such as alpha (set via setAlpha).int
getAlpha()
Returns the alpha value of this drawable's color.int
getColor()
Gets the drawable's color value.Return aDrawable.ConstantState
instance that holds the shared state of this Drawable.boolean
Indicates whether this drawable has at least one state spec explicitly specifying state_focused.boolean
Indicates whether this drawable will change its appearance based on state.mutate()
A mutable BitmapDrawable still shares its Bitmap with any other Drawable that comes from the same resource.protected boolean
onStateChange
(int[] stateSet) Override this in your subclass to change appearance if you recognize the specified state.void
setAlpha
(int alpha) Applies the given alpha to the underlying color.void
setColor
(int color) Sets the drawable's color value.void
setTintBlendMode
(BlendMode blendMode) Specifies a tint blending mode for this drawable.void
setTintList
(ColorStateList tint) Specifies tint color for this drawable as a color state list.Methods inherited from class icyllis.modernui.graphics.drawable.Drawable
applyTheme, canApplyTheme, copyBounds, copyBounds, getBounds, getCallback, getChangingConfigurations, getColorFilter, getCurrent, getHotspotBounds, getIntrinsicHeight, getIntrinsicWidth, getLayoutDirection, getLevel, getMinimumHeight, getMinimumWidth, getPadding, getState, invalidateSelf, isAutoMirrored, isVisible, jumpToCurrentState, onBoundsChange, onLayoutDirectionChanged, onLevelChange, scaleFromDensity, scaleFromDensity, scheduleSelf, setAutoMirrored, setBounds, setBounds, setCallback, setChangingConfigurations, setColorFilter, setHotspot, setHotspotBounds, setLayoutDirection, setLevel, setState, setTint, setVisible, unscheduleSelf
-
Constructor Details
-
ColorDrawable
public ColorDrawable()Creates a new black ColorDrawable. -
ColorDrawable
Creates a new ColorDrawable with the specified color.- Parameters:
color
- The color to draw.
-
-
Method Details
-
mutate
A mutable BitmapDrawable still shares its Bitmap with any other Drawable that comes from the same resource. -
clearMutated
public void clearMutated()Description copied from class:Drawable
Clears the mutated state, allowing this drawable to be cached and mutated again.- Overrides:
clearMutated
in classDrawable
-
draw
Description copied from class:Drawable
Draw in its bounds (set via setBounds) respecting optional effects such as alpha (set via setAlpha). -
getColor
Gets the drawable's color value.- Returns:
- int The color to draw.
-
setColor
Sets the drawable's color value. This action will clobber the results of prior calls tosetAlpha(int)
on this object, which side-affected the underlying color.- Parameters:
color
- The color to draw.
-
getAlpha
public int getAlpha()Returns the alpha value of this drawable's color. Note this may not be the same alpha value provided inDrawable.setAlpha(int)
. Instead, this will return the alpha of the color combined with the alpha provided by setAlpha -
setAlpha
public void setAlpha(int alpha) Applies the given alpha to the underlying color. Note if the color already has an alpha applied to it, this will apply this alpha to the existing value instead of overwriting it. -
setTintList
Description copied from class:Drawable
Specifies tint color for this drawable as a color state list.A Drawable's drawing content will be blended together with its tint before it is drawn to the screen.
Note: Setting a color filter via
Drawable.setColorFilter(ColorFilter)
overrides tint.- Overrides:
setTintList
in classDrawable
- Parameters:
tint
- Color state list to use for tinting this drawable, ornull
to clear the tint- See Also:
-
setTintBlendMode
Description copied from class:Drawable
Specifies a tint blending mode for this drawable.Defines how this drawable's tint color should be blended into the drawable before it is drawn to screen. Default tint mode is
BlendMode.SRC_IN
.Note: Setting a color filter via
Drawable.setColorFilter(ColorFilter)
- Overrides:
setTintBlendMode
in classDrawable
- Parameters:
blendMode
- BlendMode to apply to the drawable, a value of null sets the default blend mode value ofBlendMode.SRC_IN
- See Also:
-
onStateChange
Description copied from class:Drawable
Override this in your subclass to change appearance if you recognize the specified state.- Overrides:
onStateChange
in classDrawable
- Returns:
- Returns true if the state change has caused the appearance of the Drawable to change (that is, it needs to be drawn), else false if it looks the same and there is no need to redraw it since its last state.
-
isStateful
public boolean isStateful()Description copied from class:Drawable
Indicates whether this drawable will change its appearance based on state. Clients can use this to determine whether it is necessary to calculate their state and call setState.- Overrides:
isStateful
in classDrawable
- Returns:
- True if this drawable changes its appearance based on state, false otherwise.
- See Also:
-
hasFocusStateSpecified
public boolean hasFocusStateSpecified()Description copied from class:Drawable
Indicates whether this drawable has at least one state spec explicitly specifying state_focused.Note: A View uses a
Drawable
instance as its background and it changes its appearance based on a state. On keyboard devices, it should specify its state_focused to make sure the user knows which view is holding the focus.- Overrides:
hasFocusStateSpecified
in classDrawable
- Returns:
true
if state_focused is specified for this drawable.
-
getConstantState
Description copied from class:Drawable
Return aDrawable.ConstantState
instance that holds the shared state of this Drawable.- Overrides:
getConstantState
in classDrawable
- Returns:
- The ConstantState associated to that Drawable.
- See Also:
-