public class TileDrawable extends Drawable implements Drawable.Callback
setVisible(boolean, boolean)
indicates that it is no longer visible.Drawable.Callback, Drawable.ConstantState
Modifier and Type | Field and Description |
---|---|
protected ValueAnimator |
mFadeOutAnimator |
Constructor and Description |
---|
TileDrawable(Drawable inner,
int innerWidth,
int innerHeight,
int fadeOutDurationMs,
ExtendedBitmapDrawable.ExtendedOptions opts) |
Modifier and Type | Method and Description |
---|---|
void |
draw(Canvas canvas)
Draw in its bounds (set via setBounds) respecting optional effects such
as alpha (set via setAlpha) and color filter (set via setColorFilter).
|
protected int |
getCurrentAlpha() |
Drawable |
getInnerDrawable() |
int |
getOpacity()
Return the opacity/transparency of this Drawable.
|
void |
invalidateDrawable(Drawable who)
Called when the drawable needs to be redrawn.
|
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 |
reset() |
void |
scheduleDrawable(Drawable who,
Runnable what,
long when)
A Drawable can call this to schedule the next frame of its
animation.
|
void |
setAlpha(int alpha)
Specify an alpha value for the drawable. 0 means fully transparent, and
255 means fully opaque.
|
void |
setColorFilter(ColorFilter cf)
Specify an optional color filter for the drawable.
|
void |
setInnerAlpha(int alpha)
Changes the alpha on just the inner wrapped drawable.
|
boolean |
setVisible(boolean visible) |
boolean |
setVisible(boolean visible,
boolean restart)
Set whether this Drawable is visible.
|
void |
unscheduleDrawable(Drawable who,
Runnable what)
A Drawable can call this to unschedule an action previously
scheduled with
Drawable.Callback.scheduleDrawable(android.graphics.drawable.Drawable, java.lang.Runnable, long) . |
applyTheme, canApplyTheme, clearColorFilter, clearMutated, 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, getOpticalInsets, getOutline, getPadding, getState, getTransparentRegion, inflate, inflate, invalidateSelf, isAutoMirrored, isFilterBitmap, isProjected, isStateful, isVisible, jumpToCurrentState, mutate, obtainAttributes, onLayoutDirectionChanged, onStateChange, parseTintMode, resolveOpacity, scheduleSelf, setAutoMirrored, setBounds, setBounds, setCallback, setChangingConfigurations, setColorFilter, setDither, setFilterBitmap, setHotspot, setHotspotBounds, setLayoutDirection, setLevel, setState, setTint, setTintList, setTintMode, setXfermode, unscheduleSelf
protected final ValueAnimator mFadeOutAnimator
public TileDrawable(Drawable inner, int innerWidth, int innerHeight, int fadeOutDurationMs, ExtendedBitmapDrawable.ExtendedOptions opts)
public void reset()
public Drawable getInnerDrawable()
protected void onBoundsChange(Rect bounds)
Drawable
onBoundsChange
in class Drawable
public void draw(Canvas canvas)
Drawable
public void setAlpha(int alpha)
Drawable
public void setColorFilter(ColorFilter cf)
Drawable
If a Drawable has a ColorFilter, each output pixel of the Drawable's drawing contents will be modified by the color filter before it is blended onto the render target of a Canvas.
Pass null
to remove any existing color filter.
Note: Setting a non-null
color
filter disables tint
.
setColorFilter
in class Drawable
cf
- The color filter to apply, or null
to remove the
existing color filterpublic int getOpacity()
Drawable
PixelFormat
:
PixelFormat.UNKNOWN
,
PixelFormat.TRANSLUCENT
,
PixelFormat.TRANSPARENT
, or
PixelFormat.OPAQUE
.
An OPAQUE drawable is one that draws all all content within its bounds, completely covering anything behind the drawable. A TRANSPARENT drawable is one that draws nothing within its bounds, allowing everything behind it to show through. A TRANSLUCENT drawable is a drawable in any other state, where the drawable will draw some, but not all, of the content within its bounds and at least some content behind the drawable will be visible. If the visibility of the drawable's contents cannot be determined, the safest/best return value is TRANSLUCENT.
Generally a Drawable should be as conservative as possible with the
value it returns. For example, if it contains multiple child drawables
and only shows one of them at a time, if only one of the children is
TRANSLUCENT and the others are OPAQUE then TRANSLUCENT should be
returned. You can use the method Drawable.resolveOpacity(int, int)
to perform a
standard reduction of two opacities to the appropriate single output.
Note that the returned value does not necessarily take into account a
custom alpha or color filter that has been applied by the client through
the Drawable.setAlpha(int)
or Drawable.setColorFilter(android.graphics.ColorFilter)
methods. Some subclasses,
such as BitmapDrawable
, ColorDrawable
, and GradientDrawable
,
do account for the value of Drawable.setAlpha(int)
, but the general behavior is dependent
upon the implementation of the subclass.
getOpacity
in class Drawable
PixelFormat
protected int getCurrentAlpha()
public boolean setVisible(boolean visible)
public boolean setVisible(boolean visible, boolean restart)
Drawable
setVisible
in class Drawable
visible
- Set to true if visible, false if not.restart
- You can supply true here to force the drawable to behave
as if it has just become visible, even if it had last
been set visible. Used for example to force animations
to restart.protected boolean onLevelChange(int level)
Drawable
onLevelChange
in class Drawable
public void setInnerAlpha(int alpha)
public void invalidateDrawable(Drawable who)
Drawable.Callback
invalidateDrawable
in interface Drawable.Callback
who
- The drawable that is requesting the update.public void scheduleDrawable(Drawable who, Runnable what, long when)
Drawable.Callback
Handler.postAtTime(Runnable, Object, long)
with
the parameters (what, who, when) to perform the
scheduling.scheduleDrawable
in interface Drawable.Callback
who
- The drawable being scheduled.what
- The action to execute.when
- The time (in milliseconds) to run. The timebase is
SystemClock.uptimeMillis()
public void unscheduleDrawable(Drawable who, Runnable what)
Drawable.Callback
Drawable.Callback.scheduleDrawable(android.graphics.drawable.Drawable, java.lang.Runnable, long)
. An implementation can
generally simply call
Handler.removeCallbacks(Runnable, Object)
with
the parameters (what, who) to unschedule the drawable.unscheduleDrawable
in interface Drawable.Callback
who
- The drawable being unscheduled.what
- The action being unscheduled.