Class LayerDrawable
- All Implemented Interfaces:
Drawable.Callback
-
Nested Class Summary
Nested classes/interfaces inherited from class icyllis.modernui.graphics.drawable.Drawable
Drawable.Callback, Drawable.ConstantState
-
Field Summary
Modifier and TypeFieldDescriptionstatic final int
Value used for undefined start and end insets.static final org.apache.logging.log4j.Marker
static final int
Padding mode used to nest each layer inside the padding of the previous layer.static final int
Padding mode used to stack each layer directly atop the previous layer. -
Constructor Summary
ConstructorDescriptionLayerDrawable
(Drawable... layers) Creates a new layer drawable with the list of specified layers. -
Method Summary
Modifier and TypeMethodDescriptionint
Adds a new layer containing the specifieddrawable
to the end of the layer list and returns its index.boolean
void
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).findDrawableByLayerId
(int id) Looks for a layer with the given ID and returns itsDrawable
.int
findIndexByLayerId
(int id) Returns the layer with the specifiedid
.int
getAlpha()
Gets the current alpha value for the drawable.int
Returns the bottom padding in pixels.int
Return a mask of the configuration parameters for which this drawable may change, requiring that it be re-created.Return aDrawable.ConstantState
instance that holds the shared state of this Drawable.getDrawable
(int index) Returns the drawable for the layer at the specified index.int
Returns the end padding in pixels.void
getHotspotBounds
(Rect outRect) PopulatesoutRect
with the hotspot bounds.int
getId
(int index) Returns the ID of the specified layer.int
Returns the drawable's intrinsic height.int
Returns the drawable's intrinsic width.int
getLayerGravity
(int index) int
getLayerHeight
(int index) int
getLayerInsetBottom
(int index) int
getLayerInsetEnd
(int index) int
getLayerInsetLeft
(int index) int
getLayerInsetRight
(int index) int
getLayerInsetStart
(int index) int
getLayerInsetTop
(int index) int
getLayerWidth
(int index) int
Returns the left padding in pixels.int
Returns the number of layers contained within this layer drawable.boolean
getPadding
(Rect padding) Return in padding the insets suggested by this Drawable for placing content inside the drawable's bounds.int
int
Returns the right padding in pixels.int
Returns the start padding in pixels.int
Returns the top padding in pixels.boolean
Indicates whether this drawable has at least one state spec explicitly specifying state_focused.void
Called when the drawable needs to be redrawn.boolean
Tells if this Drawable will be automatically mirrored when its layout direction is RTL right-to-left.boolean
Indicates whether this drawable will change its appearance based on state.void
If this Drawable does transition animations between states, ask that it immediately jump to the current state and skip any active animations.mutate()
Make this drawable mutable.protected void
onBoundsChange
(Rect bounds) Override this in your subclass to change appearance if you vary based on the bounds.boolean
onLayoutDirectionChanged
(int layoutDirection) Called when the drawable's resolved layout direction changes.protected boolean
onLevelChange
(int level) Override this in your subclass to change appearance if you vary based on level.protected boolean
onStateChange
(int[] state) Override this in your subclass to change appearance if you recognize the specified state.void
scheduleDrawable
(Drawable who, Runnable what, long when) A Drawable can call this to schedule the next frame of its animation.void
setAlpha
(int alpha) Specify an alpha value for the drawable.void
setAutoMirrored
(boolean mirrored) Set whether this Drawable is automatically mirrored when its layout direction is RTL (right-to left).void
setDrawable
(int index, Drawable drawable) Sets the drawable for the layer at the specified index.boolean
setDrawableByLayerId
(int id, Drawable drawable) Replaces theDrawable
for the layer with the given id.void
setHotspot
(float x, float y) Specifies the hotspot's location within the drawable.void
setHotspotBounds
(int left, int top, int right, int bottom) Sets the bounds to which the hotspot is constrained, if they should be different from the drawable bounds.void
setId
(int index, int id) Sets the ID of a layer.void
setLayerGravity
(int index, int gravity) Sets the gravity used to position or stretch the specified layer within its container.void
setLayerHeight
(int index, int h) void
setLayerInset
(int index, int l, int t, int r, int b) Specifies the insets in pixels for the drawable at the specified index.void
setLayerInsetBottom
(int index, int b) void
setLayerInsetEnd
(int index, int e) void
setLayerInsetLeft
(int index, int l) void
setLayerInsetRelative
(int index, int s, int t, int e, int b) Specifies the relative insets in pixels for the drawable at the specified index.void
setLayerInsetRight
(int index, int r) void
setLayerInsetStart
(int index, int s) void
setLayerInsetTop
(int index, int t) void
setLayerSize
(int index, int w, int h) Sets an explicit size for the specified layer.void
setLayerWidth
(int index, int w) void
setPadding
(int left, int top, int right, int bottom) Sets the absolute padding.void
setPaddingMode
(int mode) Specifies how layer padding should affect the bounds of subsequent layers.void
setPaddingRelative
(int start, int top, int end, int bottom) Sets the relative padding.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.boolean
setVisible
(boolean visible, boolean restart) Set whether this Drawable is visible.void
unscheduleDrawable
(Drawable who, Runnable what) A Drawable can call this to unschedule an action previously scheduled withDrawable.Callback.scheduleDrawable(icyllis.modernui.graphics.drawable.Drawable, java.lang.Runnable, long)
.Methods inherited from class icyllis.modernui.graphics.drawable.Drawable
applyTheme, copyBounds, copyBounds, getBounds, getCallback, getColorFilter, getCurrent, getLayoutDirection, getLevel, getMinimumHeight, getMinimumWidth, getState, invalidateSelf, isVisible, scaleFromDensity, scaleFromDensity, scheduleSelf, setBounds, setBounds, setCallback, setChangingConfigurations, setColorFilter, setLayoutDirection, setLevel, setState, setTint, unscheduleSelf
-
Field Details
-
MARKER
public static final org.apache.logging.log4j.Marker MARKER -
PADDING_MODE_NEST
public static final int PADDING_MODE_NESTPadding mode used to nest each layer inside the padding of the previous layer.- See Also:
-
PADDING_MODE_STACK
public static final int PADDING_MODE_STACKPadding mode used to stack each layer directly atop the previous layer.- See Also:
-
INSET_UNDEFINED
public static final int INSET_UNDEFINEDValue used for undefined start and end insets.- See Also:
-
-
Constructor Details
-
LayerDrawable
Creates a new layer drawable with the list of specified layers.- Parameters:
layers
- a list of drawables to use as layers in this new drawable, must be non-null
-
-
Method Details
-
canApplyTheme
public boolean canApplyTheme()- Overrides:
canApplyTheme
in classDrawable
-
addLayer
Adds a new layer containing the specifieddrawable
to the end of the layer list and returns its index.- Parameters:
dr
- The drawable to add as a new layer.- Returns:
- The index of the new layer.
-
findDrawableByLayerId
Looks for a layer with the given ID and returns itsDrawable
.If multiple layers are found for the given ID, returns the
Drawable
for the matching layer at the highest index.- Parameters:
id
- The layer ID to search for.- Returns:
- The
Drawable
for the highest-indexed layer that has the given ID, or null if not found.
-
setId
public void setId(int index, int id) Sets the ID of a layer.- Parameters:
index
- The index of the layer to modify, must be in the range0...getNumberOfLayers()-1
.id
- The id to assign to the layer.- See Also:
-
getId
public int getId(int index) Returns the ID of the specified layer.- Parameters:
index
- The index of the layer, must be in the range0...getNumberOfLayers()-1
.- Returns:
- The id of the layer or
View.NO_ID
if the layer has no id. - See Also:
-
getNumberOfLayers
public int getNumberOfLayers()Returns the number of layers contained within this layer drawable.- Returns:
- The number of layers.
-
setDrawableByLayerId
Replaces theDrawable
for the layer with the given id. -
findIndexByLayerId
public int findIndexByLayerId(int id) Returns the layer with the specifiedid
.If multiple layers have the same ID, returns the layer with the lowest index.
- Parameters:
id
- The ID of the layer to return.- Returns:
- The index of the layer with the specified ID.
-
setDrawable
Sets the drawable for the layer at the specified index.- Parameters:
index
- The index of the layer to modify, must be in the range0...getNumberOfLayers()-1
.drawable
- The drawable to set for the layer.- See Also:
-
getDrawable
Returns the drawable for the layer at the specified index.- Parameters:
index
- The index of the layer, must be in the range0...getNumberOfLayers()-1
.- Returns:
- The
Drawable
at the specified layer index. - See Also:
-
setLayerSize
public void setLayerSize(int index, int w, int h) Sets an explicit size for the specified layer.Note: Setting an explicit layer size changes the default layer gravity behavior. See
setLayerGravity(int, int)
for more information.- Parameters:
index
- the index of the layer to adjustw
- width in pixels, or -1 to use the intrinsic widthh
- height in pixels, or -1 to use the intrinsic height- See Also:
-
setLayerWidth
public void setLayerWidth(int index, int w) - Parameters:
index
- the index of the layer to adjustw
- width in pixels, or -1 to use the intrinsic width
-
getLayerWidth
public int getLayerWidth(int index) - Parameters:
index
- the index of the drawable to adjust- Returns:
- the explicit width of the layer, or -1 if not specified
- See Also:
-
setLayerHeight
public void setLayerHeight(int index, int h) - Parameters:
index
- the index of the layer to adjusth
- height in pixels, or -1 to use the intrinsic height
-
getLayerHeight
public int getLayerHeight(int index) - Parameters:
index
- the index of the drawable to adjust- Returns:
- the explicit height of the layer, or -1 if not specified
- See Also:
-
setLayerGravity
public void setLayerGravity(int index, int gravity) Sets the gravity used to position or stretch the specified layer within its container. Gravity is applied after any layer insets (seesetLayerInset(int, int, int, int, int)
) or padding (seesetPaddingMode(int)
).If gravity is specified as
Gravity.NO_GRAVITY
, the default behavior depends on whether an explicit width or height has been set (seesetLayerSize(int, int, int)
), If a dimension is not set, gravity in that direction defaults toGravity.FILL_HORIZONTAL
orGravity.FILL_VERTICAL
; otherwise, gravity in that direction defaults toGravity.LEFT
orGravity.TOP
.- Parameters:
index
- the index of the drawable to adjustgravity
- the gravity to set for the layer- See Also:
-
getLayerGravity
public int getLayerGravity(int index) - Parameters:
index
- the index of the layer- Returns:
- the gravity used to position or stretch the specified layer within its container
- See Also:
-
setLayerInset
public void setLayerInset(int index, int l, int t, int r, int b) Specifies the insets in pixels for the drawable at the specified index.- Parameters:
index
- the index of the drawable to adjustl
- number of pixels to add to the left boundt
- number of pixels to add to the top boundr
- number of pixels to subtract from the right boundb
- number of pixels to subtract from the bottom bound
-
setLayerInsetRelative
public void setLayerInsetRelative(int index, int s, int t, int e, int b) Specifies the relative insets in pixels for the drawable at the specified index.- Parameters:
index
- the index of the layer to adjusts
- number of pixels to inset from the start boundt
- number of pixels to inset from the top bounde
- number of pixels to inset from the end boundb
- number of pixels to inset from the bottom bound
-
setLayerInsetLeft
public void setLayerInsetLeft(int index, int l) - Parameters:
index
- the index of the layer to adjustl
- number of pixels to inset from the left bound
-
getLayerInsetLeft
public int getLayerInsetLeft(int index) - Parameters:
index
- the index of the layer- Returns:
- number of pixels to inset from the left bound
-
setLayerInsetRight
public void setLayerInsetRight(int index, int r) - Parameters:
index
- the index of the layer to adjustr
- number of pixels to inset from the right bound
-
getLayerInsetRight
public int getLayerInsetRight(int index) - Parameters:
index
- the index of the layer- Returns:
- number of pixels to inset from the right bound
-
setLayerInsetTop
public void setLayerInsetTop(int index, int t) - Parameters:
index
- the index of the layer to adjustt
- number of pixels to inset from the top bound
-
getLayerInsetTop
public int getLayerInsetTop(int index) - Parameters:
index
- the index of the layer- Returns:
- number of pixels to inset from the top bound
-
setLayerInsetBottom
public void setLayerInsetBottom(int index, int b) - Parameters:
index
- the index of the layer to adjustb
- number of pixels to inset from the bottom bound
-
getLayerInsetBottom
public int getLayerInsetBottom(int index) - Parameters:
index
- the index of the layer- Returns:
- number of pixels to inset from the bottom bound
-
setLayerInsetStart
public void setLayerInsetStart(int index, int s) - Parameters:
index
- the index of the layer to adjusts
- number of pixels to inset from the start bound
-
getLayerInsetStart
public int getLayerInsetStart(int index) - Parameters:
index
- the index of the layer- Returns:
- the number of pixels to inset from the start bound, or
INSET_UNDEFINED
if not specified
-
setLayerInsetEnd
public void setLayerInsetEnd(int index, int e) - Parameters:
index
- the index of the layer to adjuste
- number of pixels to inset from the end bound, orINSET_UNDEFINED
if not specified
-
getLayerInsetEnd
public int getLayerInsetEnd(int index) - Parameters:
index
- the index of the layer- Returns:
- number of pixels to inset from the end bound
-
setPaddingMode
public void setPaddingMode(int mode) Specifies how layer padding should affect the bounds of subsequent layers. The default value isPADDING_MODE_NEST
.- Parameters:
mode
- padding mode, one of:PADDING_MODE_NEST
to nest each layer inside the padding of the previous layerPADDING_MODE_STACK
to stack each layer directly atop the previous layer
- See Also:
-
getPaddingMode
public int getPaddingMode()- Returns:
- the current padding mode
- See Also:
-
invalidateDrawable
Description copied from interface:Drawable.Callback
Called when the drawable needs to be redrawn. A view at this point should invalidate itself (or at least the part of itself where the drawable appears).- Specified by:
invalidateDrawable
in interfaceDrawable.Callback
- Parameters:
who
- The drawable that is requesting the update.
-
scheduleDrawable
Description copied from interface:Drawable.Callback
A Drawable can call this to schedule the next frame of its animation. An implementation can generally simply callHandler.postAtTime(Runnable, Object, long)
with the parameters (what, who, when) to perform the scheduling.- Specified by:
scheduleDrawable
in interfaceDrawable.Callback
- Parameters:
who
- The drawable being scheduled.what
- The action to execute.when
- The time (in milliseconds) to run. The timebase isCore.timeMillis()
-
unscheduleDrawable
Description copied from interface:Drawable.Callback
A Drawable can call this to unschedule an action previously scheduled withDrawable.Callback.scheduleDrawable(icyllis.modernui.graphics.drawable.Drawable, java.lang.Runnable, long)
. An implementation can generally simply callHandler.removeCallbacks(Runnable, Object)
with the parameters (what, who) to unschedule the drawable.- Specified by:
unscheduleDrawable
in interfaceDrawable.Callback
- Parameters:
who
- The drawable being unscheduled.what
- The action being unscheduled.
-
draw
Description copied from class:Drawable
Draw in its bounds (set via setBounds) respecting optional effects such as alpha (set via setAlpha). -
getChangingConfigurations
public int getChangingConfigurations()Description copied from class:Drawable
Return a mask of the configuration parameters for which this drawable may change, requiring that it be re-created. The default implementation returns whatever was provided throughDrawable.setChangingConfigurations(int)
or 0 by default. Subclasses may extend this to or in the changing configurations of any other drawables they hold.- Overrides:
getChangingConfigurations
in classDrawable
- Returns:
- Returns a mask of the changing configuration parameters
-
getPadding
Description copied from class:Drawable
Return in padding the insets suggested by this Drawable for placing content inside the drawable's bounds. Positive values move toward the center of the Drawable (setRect.inset(int, int)
).- Overrides:
getPadding
in classDrawable
- Returns:
- true if this drawable actually has a padding, else false. When false is returned, the padding is always set to 0.
-
setPadding
public void setPadding(int left, int top, int right, int bottom) Sets the absolute padding.If padding in a dimension is specified as
-1
, the resolved padding will use the value computed according to the padding mode (seesetPaddingMode(int)
).Calling this method clears any relative padding values previously set using
setPaddingRelative(int, int, int, int)
.- Parameters:
left
- the left padding in pixels, or -1 to use computed paddingtop
- the top padding in pixels, or -1 to use computed paddingright
- the right padding in pixels, or -1 to use computed paddingbottom
- the bottom padding in pixels, or -1 to use computed padding- See Also:
-
setPaddingRelative
public void setPaddingRelative(int start, int top, int end, int bottom) Sets the relative padding.If padding in a dimension is specified as
-1
, the resolved padding will use the value computed according to the padding mode (seesetPaddingMode(int)
).Calling this method clears any absolute padding values previously set using
setPadding(int, int, int, int)
.- Parameters:
start
- the start padding in pixels, or -1 to use computed paddingtop
- the top padding in pixels, or -1 to use computed paddingend
- the end padding in pixels, or -1 to use computed paddingbottom
- the bottom padding in pixels, or -1 to use computed padding- See Also:
-
getLeftPadding
public int getLeftPadding()Returns the left padding in pixels.A return value of
-1
means there is no explicit padding set for this dimension. As a result, the value for this dimension returned bygetPadding(Rect)
will be computed from the child layers according to the padding mode (seegetPaddingMode()
.- Returns:
- the left padding in pixels, or -1 if not explicitly specified
- See Also:
-
getRightPadding
public int getRightPadding()Returns the right padding in pixels.A return value of
-1
means there is no explicit padding set for this dimension. As a result, the value for this dimension returned bygetPadding(Rect)
will be computed from the child layers according to the padding mode (seegetPaddingMode()
.- Returns:
- the right padding in pixels, or -1 if not explicitly specified
- See Also:
-
getStartPadding
public int getStartPadding()Returns the start padding in pixels.A return value of
-1
means there is no explicit padding set for this dimension. As a result, the value for this dimension returned bygetPadding(Rect)
will be computed from the child layers according to the padding mode (seegetPaddingMode()
.- Returns:
- the start padding in pixels, or -1 if not explicitly specified
- See Also:
-
getEndPadding
public int getEndPadding()Returns the end padding in pixels.A return value of
-1
means there is no explicit padding set for this dimension. As a result, the value for this dimension returned bygetPadding(Rect)
will be computed from the child layers according to the padding mode (seegetPaddingMode()
.- Returns:
- the end padding in pixels, or -1 if not explicitly specified
- See Also:
-
getTopPadding
public int getTopPadding()Returns the top padding in pixels.A return value of
-1
means there is no explicit padding set for this dimension. As a result, the value for this dimension returned bygetPadding(Rect)
will be computed from the child layers according to the padding mode (seegetPaddingMode()
.- Returns:
- the top padding in pixels, or -1 if not explicitly specified
- See Also:
-
getBottomPadding
public int getBottomPadding()Returns the bottom padding in pixels.A return value of
-1
means there is no explicit padding set for this dimension. As a result, the value for this dimension returned bygetPadding(Rect)
will be computed from the child layers according to the padding mode (seegetPaddingMode()
.- Returns:
- the bottom padding in pixels, or -1 if not explicitly specified
- See Also:
-
setHotspot
public void setHotspot(float x, float y) Description copied from class:Drawable
Specifies the hotspot's location within the drawable.- Overrides:
setHotspot
in classDrawable
- Parameters:
x
- The X coordinate of the center of the hotspoty
- The Y coordinate of the center of the hotspot
-
setHotspotBounds
public void setHotspotBounds(int left, int top, int right, int bottom) Description copied from class:Drawable
Sets the bounds to which the hotspot is constrained, if they should be different from the drawable bounds.- Overrides:
setHotspotBounds
in classDrawable
- Parameters:
left
- position in pixels of the left boundtop
- position in pixels of the top boundright
- position in pixels of the right boundbottom
- position in pixels of the bottom bound- See Also:
-
getHotspotBounds
Description copied from class:Drawable
PopulatesoutRect
with the hotspot bounds.- Overrides:
getHotspotBounds
in classDrawable
- Parameters:
outRect
- the rect to populate with the hotspot bounds- See Also:
-
setVisible
public boolean setVisible(boolean visible, boolean restart) Description copied from class:Drawable
Set whether this Drawable is visible. This generally does not impact the Drawable's behavior, but is a hint that can be used by some Drawables, for example, to decide whether run animations.- Overrides:
setVisible
in classDrawable
- Parameters:
visible
- Set to true if visible, false if not.restart
- You can supply true here to force the drawable to behave as if it has just become visible, even if it had last been set visible. Used for example to force animations to restart.- Returns:
- true if the new visibility is different from its previous state.
-
setAlpha
public void setAlpha(int alpha) Description copied from class:Drawable
Specify an alpha value for the drawable. 0 means fully transparent, and 255 means fully opaque. -
getAlpha
public int getAlpha()Description copied from class:Drawable
Gets the current alpha value for the drawable. 0 means fully transparent, 255 means fully opaque. This method is implemented by Drawable subclasses and the value returned is specific to how that class treats alpha. The default return value is 255 if the class does not override this method to return a value specific to its use of alpha. -
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:
-
setAutoMirrored
public void setAutoMirrored(boolean mirrored) Description copied from class:Drawable
Set whether this Drawable is automatically mirrored when its layout direction is RTL (right-to left). SeeLayoutDirection
.- Overrides:
setAutoMirrored
in classDrawable
- Parameters:
mirrored
- Set to true if the Drawable should be mirrored, false if not.
-
isAutoMirrored
public boolean isAutoMirrored()Description copied from class:Drawable
Tells if this Drawable will be automatically mirrored when its layout direction is RTL right-to-left. SeeLayoutDirection
.- Overrides:
isAutoMirrored
in classDrawable
- Returns:
- boolean Returns true if this Drawable will be automatically mirrored.
-
jumpToCurrentState
public void jumpToCurrentState()Description copied from class:Drawable
If this Drawable does transition animations between states, ask that it immediately jump to the current state and skip any active animations.- Overrides:
jumpToCurrentState
in classDrawable
-
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.
-
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.
-
onLevelChange
protected boolean onLevelChange(int level) Description copied from class:Drawable
Override this in your subclass to change appearance if you vary based on level.- Overrides:
onLevelChange
in classDrawable
- Returns:
- Returns true if the level 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 level.
-
onBoundsChange
Description copied from class:Drawable
Override this in your subclass to change appearance if you vary based on the bounds.- Overrides:
onBoundsChange
in classDrawable
-
getIntrinsicWidth
public int getIntrinsicWidth()Description copied from class:Drawable
Returns the drawable's intrinsic width.Intrinsic width is the width at which the drawable would like to be laid out, including any inherent padding. If the drawable has no intrinsic width, such as a solid color, this method returns -1.
- Overrides:
getIntrinsicWidth
in classDrawable
- Returns:
- the intrinsic width, or -1 if no intrinsic width
-
getIntrinsicHeight
public int getIntrinsicHeight()Description copied from class:Drawable
Returns the drawable's intrinsic height.Intrinsic height is the height at which the drawable would like to be laid out, including any inherent padding. If the drawable has no intrinsic height, such as a solid color, this method returns -1.
- Overrides:
getIntrinsicHeight
in classDrawable
- Returns:
- the intrinsic height, or -1 if no intrinsic height
-
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:
-
mutate
Description copied from class:Drawable
Make this drawable mutable. This operation cannot be reversed. A mutable drawable is guaranteed to not share its state with any other drawable. This is especially useful when you need to modify properties of drawables loaded from resources. By default, all drawables instances loaded from the same resource share a common state; if you modify the state of one instance, all the other instances will receive the same modification.Calling this method on a mutable Drawable will have no effect.
-
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
-
onLayoutDirectionChanged
public boolean onLayoutDirectionChanged(int layoutDirection) Description copied from class:Drawable
Called when the drawable's resolved layout direction changes.- Overrides:
onLayoutDirectionChanged
in classDrawable
- Parameters:
layoutDirection
- the new resolved layout direction- Returns:
true
if the layout direction change has caused the appearance of the drawable to change such that it needs to be re-drawn,false
otherwise- See Also:
-