Class ScaleDrawable
java.lang.Object
icyllis.modernui.graphics.drawable.Drawable
icyllis.modernui.graphics.drawable.DrawableWrapper
icyllis.modernui.graphics.drawable.ScaleDrawable
- 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
-
Constructor Summary
ConstructorDescriptionScaleDrawable
(Drawable drawable, int gravity, float scaleWidth, float scaleHeight) Creates a new scale drawable with the specified gravity and scale properties. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Draw in its bounds (set via setBounds) respecting optional effects such as alpha (set via setAlpha).protected void
onBoundsChange
(Rect bounds) Override this in your subclass to change appearance if you vary based on the bounds.protected boolean
onLevelChange
(int level) Override this in your subclass to change appearance if you vary based on level.void
setGravity
(int gravity) void
setScaleHeight
(float scaleHeight) void
setScaleWidth
(float scaleWidth) Methods inherited from class icyllis.modernui.graphics.drawable.DrawableWrapper
clearMutated, getAlpha, getConstantState, getDrawable, getHotspotBounds, getIntrinsicHeight, getIntrinsicWidth, getPadding, hasFocusStateSpecified, invalidateDrawable, isStateful, jumpToCurrentState, mutate, 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, getLayoutDirection, getLevel, getMinimumHeight, getMinimumWidth, getState, invalidateSelf, isAutoMirrored, isVisible, scaleFromDensity, scaleFromDensity, scheduleSelf, setAutoMirrored, setBounds, setBounds, setCallback, setChangingConfigurations, setColorFilter, setLayoutDirection, setLevel, setState, setTint, unscheduleSelf
-
Constructor Details
-
ScaleDrawable
Creates a new scale drawable with the specified gravity and scale properties.- Parameters:
drawable
- the drawable to scalegravity
- gravity constant (seeGravity
used to position the scaled drawable within the parent containerscaleWidth
- width scaling factor [0...1] to use then the level is at the maximum value, or -1 to not scale widthscaleHeight
- height scaling factor [0...1] to use then the level is at the maximum value, or -1 to not scale height
-
-
Method Details
-
setGravity
public void setGravity(int gravity) -
setScaleWidth
public void setScaleWidth(float scaleWidth) -
setScaleHeight
public void setScaleHeight(float scaleHeight) -
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
-
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.
-
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
-