public class ClipDrawable extends Drawable implements Drawable.Callback
setLevel()
.
Note: The drawable is clipped completely and not visible when the level is 0 and fully revealed when the level is 10,000.
It can be defined in an XML file with the <clip>
element. For more
information, see the guide to Drawable Resources.
Drawable.Callback, Drawable.ConstantState
Modifier and Type | Field and Description |
---|---|
static int |
HORIZONTAL |
static int |
VERTICAL |
Constructor and Description |
---|
ClipDrawable(Drawable drawable,
int gravity,
int orientation) |
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).
|
int |
getChangingConfigurations()
Return a mask of the configuration parameters for which this drawable
may change, requiring that it be re-created.
|
Drawable.ConstantState |
getConstantState()
Return a
Drawable.ConstantState instance that holds the shared state of this Drawable. |
int |
getIntrinsicHeight()
Return the intrinsic height of the underlying drawable object.
|
int |
getIntrinsicWidth()
Return the intrinsic width of the underlying drawable object.
|
int |
getOpacity()
Return the opacity/transparency of this Drawable.
|
boolean |
getPadding(Rect padding)
Return in padding the insets suggested by this Drawable for placing
content inside the drawable's bounds.
|
void |
inflate(Resources r,
XmlPullParser parser,
AttributeSet attrs)
Inflate this Drawable from an XML resource.
|
void |
invalidateDrawable(Drawable who)
Called when the drawable needs to be redrawn.
|
boolean |
isStateful()
Indicates whether this view will change its appearance based on state.
|
protected void |
onBoundsChange(Rect bounds)
Override this in your subclass to change appearance if you recognize the
specified state.
|
protected boolean |
onLevelChange(int level)
Override this in your subclass to change appearance if you vary based
on level.
|
protected boolean |
onStateChange(int[] state)
Override this in your subclass to change appearance if you recognize the
specified state.
|
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.
|
void |
setColorFilter(ColorFilter cf)
Specify an optional colorFilter for the drawable.
|
void |
setLayoutDirection(int layoutDirection)
Set the layout direction for this drawable.
|
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) . |
clearColorFilter, copyBounds, copyBounds, createFromPath, createFromResourceStream, createFromResourceStream, createFromStream, createFromXml, createFromXmlInner, getBounds, getCallback, getCurrent, getLayoutDirection, getLayoutInsets, getLevel, getMinimumHeight, getMinimumWidth, getState, getTransparentRegion, invalidateSelf, isVisible, jumpToCurrentState, mutate, resolveOpacity, scheduleSelf, setBounds, setBounds, setCallback, setChangingConfigurations, setColorFilter, setDither, setFilterBitmap, setLevel, setState, unscheduleSelf
public static final int HORIZONTAL
public static final int VERTICAL
public ClipDrawable(Drawable drawable, int gravity, int orientation)
orientation
- Bitwise-or of HORIZONTAL
and/or VERTICAL
public void inflate(Resources r, XmlPullParser parser, AttributeSet attrs) throws XmlPullParserException, IOException
Drawable
inflate
in class Drawable
XmlPullParserException
IOException
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.public int getChangingConfigurations()
Drawable
Drawable.setChangingConfigurations(int)
or 0 by default. Subclasses
may extend this to or in the changing configurations of any other
drawables they hold.getChangingConfigurations
in class Drawable
Configuration
.Configuration
public boolean getPadding(Rect padding)
Drawable
getPadding
in class Drawable
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.public void setAlpha(int alpha)
Drawable
public void setColorFilter(ColorFilter cf)
Drawable
setColorFilter
in class Drawable
public int getOpacity()
Drawable
PixelFormat
:
PixelFormat.UNKNOWN
,
PixelFormat.TRANSLUCENT
,
PixelFormat.TRANSPARENT
, or
PixelFormat.OPAQUE
.
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 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.
getOpacity
in class Drawable
PixelFormat
public boolean isStateful()
Drawable
isStateful
in class Drawable
Drawable.setState(int[])
protected boolean onStateChange(int[] state)
Drawable
onStateChange
in class Drawable
protected boolean onLevelChange(int level)
Drawable
onLevelChange
in class Drawable
protected void onBoundsChange(Rect bounds)
Drawable
onBoundsChange
in class Drawable
public void draw(Canvas canvas)
Drawable
public int getIntrinsicWidth()
Drawable
getIntrinsicWidth
in class Drawable
public int getIntrinsicHeight()
Drawable
getIntrinsicHeight
in class Drawable
public Drawable.ConstantState getConstantState()
Drawable
Drawable.ConstantState
instance that holds the shared state of this Drawable.
qgetConstantState
in class Drawable
Drawable.ConstantState
,
Drawable.mutate()
public void setLayoutDirection(int layoutDirection)
Drawable
setLayoutDirection
in class Drawable
layoutDirection
- One of View.LAYOUT_DIRECTION_LTR
,
View.LAYOUT_DIRECTION_RTL