Class ClipDrawable
java.lang.Object
icyllis.modernui.graphics.drawable.Drawable
icyllis.modernui.graphics.drawable.DrawableWrapper
icyllis.modernui.graphics.drawable.ClipDrawable
- All Implemented Interfaces:
Drawable.Callback
A Drawable that clips another Drawable based on this Drawable's current
level value. You can control how much the child Drawable gets clipped in width
and height based on the level, as well as a gravity to control where it is
placed in its overall container. Most often used to implement things like
progress bars, by increasing the drawable's level with
setLevel()
.
Note: The drawable is clipped completely and not visible when the level is 0 and fully revealed when the level is 10,000.
-
Nested Class Summary
Nested classes/interfaces inherited from class icyllis.modernui.graphics.drawable.Drawable
Drawable.Callback, Drawable.ConstantState
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionClipDrawable
(Drawable drawable, int gravity, int orientation) Creates a new clip drawable with the specified gravity and orientation. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Draw in its bounds (set via setBounds) respecting optional effects such as alpha (set via setAlpha).protected boolean
onLevelChange
(int level) Override this in your subclass to change appearance if you vary based on level.Methods inherited from class icyllis.modernui.graphics.drawable.DrawableWrapper
clearMutated, getAlpha, getConstantState, getDrawable, getHotspotBounds, getIntrinsicHeight, getIntrinsicWidth, getOutline, getPadding, hasFocusStateSpecified, invalidateDrawable, isStateful, jumpToCurrentState, mutate, onBoundsChange, onLayoutDirectionChanged, 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
-
Field Details
-
HORIZONTAL
public static final int HORIZONTAL- See Also:
-
VERTICAL
public static final int VERTICAL- See Also:
-
-
Constructor Details
-
ClipDrawable
Creates a new clip drawable with the specified gravity and orientation.- Parameters:
drawable
- the drawable to clipgravity
- gravity constant (seeGravity
used to position the clipped drawable within the parent containerorientation
- bitwise-or ofHORIZONTAL
and/orVERTICAL
-
-
Method Details
-
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 classDrawableWrapper
- 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.
-
draw
Description copied from class:Drawable
Draw in its bounds (set via setBounds) respecting optional effects such as alpha (set via setAlpha).- Overrides:
draw
in classDrawableWrapper
- Parameters:
canvas
- The canvas to draw into
-