Class InsetDrawable
java.lang.Object
icyllis.modernui.graphics.drawable.Drawable
icyllis.modernui.graphics.drawable.DrawableWrapper
icyllis.modernui.graphics.drawable.InsetDrawable
- All Implemented Interfaces:
Drawable.Callback
A Drawable that insets another Drawable by a specified distance or fraction of the content bounds.
This is used when a View needs a background that is smaller than
the View's actual bounds.
-
Nested Class Summary
Nested classes/interfaces inherited from class icyllis.modernui.graphics.drawable.Drawable
Drawable.Callback, Drawable.ConstantState
-
Field Summary
-
Constructor Summary
ConstructorsConstructorDescriptionInsetDrawable
(Drawable drawable, float inset) Creates a new inset drawable with the specified inset.InsetDrawable
(Drawable drawable, float insetLeftFraction, float insetTopFraction, float insetRightFraction, float insetBottomFraction) Creates a new inset drawable with the specified insets in fraction of the view bounds.InsetDrawable
(Drawable drawable, int inset) Creates a new inset drawable with the specified inset.InsetDrawable
(Drawable drawable, int insetLeft, int insetTop, int insetRight, int insetBottom) Creates a new inset drawable with the specified insets in pixels. -
Method Summary
Modifier and TypeMethodDescriptionint
Returns the drawable's intrinsic height.int
Returns the drawable's intrinsic width.boolean
getPadding
(Rect padding) Return in padding the insets suggested by this Drawable for placing content inside the drawable's bounds.protected void
onBoundsChange
(Rect bounds) Override this in your subclass to change appearance if you vary based on the bounds.Methods inherited from class icyllis.modernui.graphics.drawable.DrawableWrapper
clearMutated, draw, getAlpha, getConstantState, getDrawable, getHotspotBounds, getOutline, hasFocusStateSpecified, invalidateDrawable, isStateful, jumpToCurrentState, mutate, onLayoutDirectionChanged, onLevelChange, onStateChange, scheduleDrawable, setAlpha, setDrawable, setHotspot, setHotspotBounds, setTintBlendMode, setTintList, setVisible, unscheduleDrawable
Methods inherited from class icyllis.modernui.graphics.drawable.Drawable
applyTheme, canApplyTheme, copyBounds, copyBounds, getBounds, getCallback, getChangingConfigurations, getColorFilter, getCurrent, getDirtyBounds, getLayoutDirection, getLevel, getMinimumHeight, getMinimumWidth, getState, invalidateSelf, isAutoMirrored, isVisible, scaleFromDensity, scaleFromDensity, scheduleSelf, setAutoMirrored, setBounds, setBounds, setCallback, setChangingConfigurations, setColorFilter, setLayoutDirection, setLevel, setState, setTint, unscheduleSelf
-
Constructor Details
-
InsetDrawable
Creates a new inset drawable with the specified inset.- Parameters:
drawable
- The drawable to inset.inset
- Inset in pixels around the drawable.
-
InsetDrawable
Creates a new inset drawable with the specified inset.- Parameters:
drawable
- The drawable to inset.inset
- Inset in fraction (range: [0, 1)) of the inset content bounds.
-
InsetDrawable
public InsetDrawable(@Nullable Drawable drawable, int insetLeft, int insetTop, int insetRight, int insetBottom) Creates a new inset drawable with the specified insets in pixels.- Parameters:
drawable
- The drawable to inset.insetLeft
- Left inset in pixels.insetTop
- Top inset in pixels.insetRight
- Right inset in pixels.insetBottom
- Bottom inset in pixels.
-
InsetDrawable
public InsetDrawable(@Nullable Drawable drawable, float insetLeftFraction, float insetTopFraction, float insetRightFraction, float insetBottomFraction) Creates a new inset drawable with the specified insets in fraction of the view bounds.- Parameters:
drawable
- The drawable to inset.insetLeftFraction
- Left inset in fraction (range: [0, 1)) of the inset content bounds.insetTopFraction
- Top inset in fraction (range: [0, 1)) of the inset content bounds.insetRightFraction
- Right inset in fraction (range: [0, 1)) of the inset content bounds.insetBottomFraction
- Bottom inset in fraction (range: [0, 1)) of the inset content bounds.
-
-
Method Details
-
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 classDrawableWrapper
- Returns:
- true if this drawable actually has a padding, else false. When false is returned, the padding is always set to 0.
-
onBoundsChange
Description copied from class:Drawable
Override this in your subclass to change appearance if you vary based on the bounds.- Overrides:
onBoundsChange
in classDrawableWrapper
-
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 classDrawableWrapper
- 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 classDrawableWrapper
- Returns:
- the intrinsic height, or -1 if no intrinsic height
-