Class ColorDrawable
-
Nested Class Summary
Nested classes/interfaces inherited from class icyllis.modernui.graphics.drawable.Drawable
Drawable.Callback, Drawable.ConstantState -
Field Summary
-
Constructor Summary
ConstructorsConstructorDescriptionCreates a new black ColorDrawable.ColorDrawable(int color) Creates a new ColorDrawable with the specified color. -
Method Summary
Modifier and TypeMethodDescriptionvoidClears the mutated state, allowing this drawable to be cached and mutated again.voidDraw in its bounds (set via setBounds) respecting optional effects such as alpha (set via setAlpha).intgetAlpha()Returns the alpha value of this drawable's color.intgetColor()Gets the drawable's color value.Return aDrawable.ConstantStateinstance that holds the shared state of this Drawable.voidgetOutline(Outline outline) Called to get the drawable to populate the Outline that defines its drawing area.booleanIndicates whether this drawable has at least one state spec explicitly specifying state_focused.booleanIndicates 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 booleanonStateChange(int[] stateSet) Override this in your subclass to change appearance if you recognize the specified state.voidsetAlpha(int alpha) Applies the given alpha to the underlying color.voidsetColor(int color) Sets the drawable's color value.voidsetTintBlendMode(BlendMode blendMode) Specifies a tint blending mode for this drawable.voidsetTintList(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, getDirtyBounds, 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:DrawableClears the mutated state, allowing this drawable to be cached and mutated again.- Overrides:
clearMutatedin classDrawable
-
draw
Description copied from class:DrawableDraw 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:DrawableSpecifies 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:
setTintListin classDrawable- Parameters:
tint- Color state list to use for tinting this drawable, ornullto clear the tint- See Also:
-
setTintBlendMode
Description copied from class:DrawableSpecifies 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:
setTintBlendModein 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:DrawableOverride this in your subclass to change appearance if you recognize the specified state.- Overrides:
onStateChangein 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:DrawableIndicates 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:
isStatefulin classDrawable- Returns:
- True if this drawable changes its appearance based on state, false otherwise.
- See Also:
-
hasFocusStateSpecified
public boolean hasFocusStateSpecified()Description copied from class:DrawableIndicates whether this drawable has at least one state spec explicitly specifying state_focused.Note: A View uses a
Drawableinstance 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:
hasFocusStateSpecifiedin classDrawable- Returns:
trueif state_focused is specified for this drawable.
-
getOutline
Description copied from class:DrawableCalled to get the drawable to populate the Outline that defines its drawing area.This method is called by the default
ViewOutlineProviderto define the outline of the View.The default behavior defines the outline to be the bounding rectangle of 0 alpha. Subclasses that wish to convey a different shape or alpha value must override this method.
- Overrides:
getOutlinein classDrawable- See Also:
-
getConstantState
Description copied from class:DrawableReturn aDrawable.ConstantStateinstance that holds the shared state of this Drawable.- Overrides:
getConstantStatein classDrawable- Returns:
- The ConstantState associated to that Drawable.
- See Also:
-