Class LevelListDrawable
java.lang.Object
icyllis.modernui.graphics.drawable.Drawable
icyllis.modernui.graphics.drawable.DrawableContainer
icyllis.modernui.graphics.drawable.LevelListDrawable
- All Implemented Interfaces:
Drawable.Callback
A resource that manages a number of alternate Drawables, each assigned a maximum numerical value.
Setting the level value of the object with
Drawable.setLevel(int)
will load the image with the next
greater or equal value assigned to its max attribute.
A good example use of a LevelListDrawable would be a Wi-Fi signal strength indicator icon, with different images to indicate the current signal level.
-
Nested Class Summary
Nested classes/interfaces inherited from class icyllis.modernui.graphics.drawable.DrawableContainer
DrawableContainer.DrawableContainerState
Nested classes/interfaces inherited from class icyllis.modernui.graphics.drawable.Drawable
Drawable.Callback, Drawable.ConstantState
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
void
Clears the mutated state, allowing this drawable to be cached and mutated again.mutate()
Make this drawable mutable.protected boolean
onLevelChange
(int level) Override this in your subclass to change appearance if you vary based on level.protected void
Methods inherited from class icyllis.modernui.graphics.drawable.DrawableContainer
draw, getAlpha, getConstantState, getCurrent, getCurrentIndex, getHotspotBounds, getIntrinsicHeight, getIntrinsicWidth, getMinimumHeight, getMinimumWidth, getPadding, hasFocusStateSpecified, invalidateDrawable, isAutoMirrored, isStateful, jumpToCurrentState, onBoundsChange, onLayoutDirectionChanged, onStateChange, scheduleDrawable, selectDrawable, setAlpha, setAutoMirrored, setEnterFadeDuration, setExitFadeDuration, setHotspot, setHotspotBounds, setTintBlendMode, setTintList, setVisible, unscheduleDrawable
Methods inherited from class icyllis.modernui.graphics.drawable.Drawable
applyTheme, canApplyTheme, copyBounds, copyBounds, getBounds, getCallback, getChangingConfigurations, getColorFilter, getLayoutDirection, getLevel, getState, invalidateSelf, isVisible, scaleFromDensity, scaleFromDensity, scheduleSelf, setBounds, setBounds, setCallback, setChangingConfigurations, setColorFilter, setLayoutDirection, setLevel, setState, setTint, unscheduleSelf
-
Constructor Details
-
LevelListDrawable
public LevelListDrawable()
-
-
Method Details
-
addLevel
-
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 classDrawableContainer
- 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.
-
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.
- Overrides:
mutate
in classDrawableContainer
- Returns:
- This drawable.
- See Also:
-
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 classDrawableContainer
-
setConstantState
- Overrides:
setConstantState
in classDrawableContainer
-