public class RhythmDrawable
extends android.graphics.drawable.Drawable
Renders the currently assigned RhythmOverlay
and serves as an adapter between Rhythm (which sets the
overlay to draw by this drawable at the moment) and the views where the overlay (grids, keylines etc) must be
applied. You can use it as any other Drawable
from Android SDK, e.g. assign it as background, foreground,
overlay etc, but keep in mind that for different views, separate drawable instances must be created.
For easy
integration with existing layouts, RhythmDrawable
can decorate another Drawable
—
that is, draw the decorated one below and then the overlay atop. This can be especially useful when decorating the
views that already have backgrounds. Note: as of this version, decoration logic is very limited for the sake
of simplicity, therefore in some cases (e.g. when decorated drawable is a state list or a level list), it may not
respond correctly to state and level changes (e.g. pressing a decorated button won’t highlight it). But since
decoration is mostly intended for ViewGroups, it’s unlikely that this should be an issue under normal use.
Normally you shouldn’t extend this class. If you need to perform custom drawing, consider creating a custom RhythmSpecLayer
implementation instead.
Modifier and Type | Field and Description |
---|---|
protected android.graphics.drawable.Drawable |
mDecorated |
protected RhythmOverlay |
mOverlay |
Constructor and Description |
---|
RhythmDrawable(RhythmOverlay overlay)
Create a Rhythm drawable for given Rhythm overlay.
|
Modifier and Type | Method and Description |
---|---|
void |
draw(android.graphics.Canvas canvas) |
android.graphics.drawable.Drawable |
getDecorated()
Get decorated drawable (the one drawn under the overlay) if present
|
int |
getOpacity() |
RhythmOverlay |
getOverlay()
Get current overlay
|
boolean |
getPadding(android.graphics.Rect padding) |
int[] |
getState() |
boolean |
isStateful() |
protected void |
onBoundsChange(android.graphics.Rect bounds) |
protected boolean |
onLevelChange(int level) |
protected boolean |
onStateChange(int[] state) |
void |
setAlpha(int alpha) |
void |
setColorFilter(android.graphics.ColorFilter colorFilter) |
void |
setDecorated(android.graphics.drawable.Drawable decorated)
Set a
Drawable to decorate. |
void |
setOverlay(RhythmOverlay overlay)
Set a
RhythmOverlay for this drawable. |
boolean |
setState(int[] stateSet) |
applyTheme, canApplyTheme, clearColorFilter, copyBounds, copyBounds, createFromPath, createFromResourceStream, createFromResourceStream, createFromStream, createFromXml, createFromXml, createFromXmlInner, createFromXmlInner, getAlpha, getBounds, getCallback, getChangingConfigurations, getColorFilter, getConstantState, getCurrent, getDirtyBounds, getHotspotBounds, getIntrinsicHeight, getIntrinsicWidth, getLayoutDirection, getLevel, getMinimumHeight, getMinimumWidth, getOutline, getTransparentRegion, inflate, inflate, invalidateSelf, isAutoMirrored, isFilterBitmap, isVisible, jumpToCurrentState, mutate, onLayoutDirectionChanged, resolveOpacity, scheduleSelf, setAutoMirrored, setBounds, setBounds, setCallback, setChangingConfigurations, setColorFilter, setDither, setFilterBitmap, setHotspot, setHotspotBounds, setLayoutDirection, setLevel, setTint, setTintList, setTintMode, setVisible, unscheduleSelf
protected RhythmOverlay mOverlay
protected android.graphics.drawable.Drawable mDecorated
public RhythmDrawable(@Nullable RhythmOverlay overlay)
setOverlay(RhythmOverlay)
method.overlay
- Rhythm overlay to render into this drawable, can be null
.public void draw(android.graphics.Canvas canvas)
draw
in class android.graphics.drawable.Drawable
public RhythmOverlay getOverlay()
null
if no overlay is setpublic void setOverlay(@Nullable RhythmOverlay overlay)
RhythmOverlay
for this drawable. Will request redraw of this drawable’s view.overlay
- Overlay to draw. Provide null
to disable overlay.public android.graphics.drawable.Drawable getDecorated()
null
public void setDecorated(@Nullable android.graphics.drawable.Drawable decorated)
Drawable
to decorate. Should be used when decorating an existing background or foreground of a view
— this way the original drawable will be preserved and the overlay will be drawn atop. Note: to
function properly, the decorated drawable’s callbacks
must be set. Also
see the class’ description
for more info on decoration support.decorated
- A drawable to draw below the overlay. Set null
to remove decorated drawable.public void setAlpha(int alpha)
setAlpha
in class android.graphics.drawable.Drawable
public void setColorFilter(android.graphics.ColorFilter colorFilter)
setColorFilter
in class android.graphics.drawable.Drawable
public int getOpacity()
getOpacity
in class android.graphics.drawable.Drawable
public boolean isStateful()
isStateful
in class android.graphics.drawable.Drawable
public boolean setState(int[] stateSet)
setState
in class android.graphics.drawable.Drawable
public int[] getState()
getState
in class android.graphics.drawable.Drawable
public boolean getPadding(@NonNull android.graphics.Rect padding)
getPadding
in class android.graphics.drawable.Drawable
protected boolean onStateChange(int[] state)
onStateChange
in class android.graphics.drawable.Drawable
protected boolean onLevelChange(int level)
onLevelChange
in class android.graphics.drawable.Drawable
protected void onBoundsChange(android.graphics.Rect bounds)
onBoundsChange
in class android.graphics.drawable.Drawable