public class UserIconDrawable extends Drawable implements Drawable.Callback
Drawable.Callback, Drawable.ConstantState
Constructor and Description |
---|
UserIconDrawable() |
UserIconDrawable(int intrinsicSize)
Use this constructor if the drawable is intended to be placed in listviews
|
Modifier and Type | Method and Description |
---|---|
UserIconDrawable |
bake()
This 'bakes' the current state of this icon into a bitmap and removes/recycles the source
bitmap/drawable.
|
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 |
getIntrinsicHeight()
Returns the drawable's intrinsic height.
|
int |
getIntrinsicWidth()
Returns the drawable's intrinsic width.
|
static Drawable |
getManagedUserBadgeDrawable(Context context)
Gets the system default managed-user badge as a drawable
|
int |
getOpacity()
Return the opacity/transparency of this Drawable.
|
static int |
getSizeForList(Context context)
Gets the preferred list-item size of this drawable.
|
void |
invalidateDrawable(Drawable who)
Called when the drawable needs to be redrawn.
|
void |
invalidateSelf()
Use the current
Drawable.Callback implementation to have this Drawable
redrawn. |
boolean |
isStateful()
Indicates whether this drawable will change its appearance based on
state.
|
protected void |
onBoundsChange(Rect bounds)
Override this in your subclass to change appearance if you vary based on
the bounds.
|
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.
|
UserIconDrawable |
setBadge(Drawable badge) |
UserIconDrawable |
setBadgeIfManagedUser(Context context,
int userId) |
void |
setBadgeMargin(float margin) |
void |
setBadgeRadius(float radius) |
void |
setColorFilter(ColorFilter colorFilter)
Specify an optional color filter for the drawable.
|
void |
setFrameColor(ColorStateList colorList) |
void |
setFrameColor(int color) |
void |
setFramePadding(float padding) |
void |
setFrameWidth(float width) |
UserIconDrawable |
setIcon(Bitmap icon) |
UserIconDrawable |
setIconDrawable(Drawable icon) |
void |
setIntrinsicSize(int size)
This sets the "intrinsic" size of this drawable.
|
void |
setPadding(float padding)
Sets global padding of icon/frame.
|
void |
setTintList(ColorStateList tintList)
Specifies tint color for this drawable as a color state list.
|
void |
setTintMode(PorterDuff.Mode mode)
Specifies a tint blending mode for this drawable.
|
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, getLayoutDirection, getLevel, getMinimumHeight, getMinimumWidth, getOpticalInsets, getOutline, getPadding, getState, getTransparentRegion, inflate, inflate, isAutoMirrored, isFilterBitmap, isProjected, isVisible, jumpToCurrentState, mutate, obtainAttributes, onLayoutDirectionChanged, onLevelChange, onStateChange, parseTintMode, resolveOpacity, scheduleSelf, setAutoMirrored, setBounds, setBounds, setCallback, setChangingConfigurations, setColorFilter, setDither, setFilterBitmap, setHotspot, setHotspotBounds, setLayoutDirection, setLevel, setState, setTint, setVisible, setXfermode, unscheduleSelf
public UserIconDrawable()
public UserIconDrawable(int intrinsicSize)
intrinsicSize
- if 0, the intrinsic size will come from the icon itselfpublic static Drawable getManagedUserBadgeDrawable(Context context)
context
- public static int getSizeForList(Context context)
context
- public UserIconDrawable setIcon(Bitmap icon)
public UserIconDrawable setIconDrawable(Drawable icon)
public UserIconDrawable setBadge(Drawable badge)
public UserIconDrawable setBadgeIfManagedUser(Context context, int userId)
public void setBadgeRadius(float radius)
public void setBadgeMargin(float margin)
public void setPadding(float padding)
padding
- public void setFrameWidth(float width)
public void setFramePadding(float padding)
public void setFrameColor(int color)
public void setFrameColor(ColorStateList colorList)
public void setIntrinsicSize(int size)
size
- if 0, the intrinsic size will be set to the displayed icon's sizepublic void draw(Canvas canvas)
Drawable
public void setAlpha(int alpha)
Drawable
public void setColorFilter(ColorFilter colorFilter)
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
colorFilter
- The color filter to apply, or null
to remove the
existing color filterpublic void setTintList(ColorStateList tintList)
Drawable
A Drawable's drawing content will be blended together with its tint
before it is drawn to the screen. This functions similarly to
Drawable.setColorFilter(int, PorterDuff.Mode)
.
Note: Setting a color filter via
Drawable.setColorFilter(ColorFilter)
or
Drawable.setColorFilter(int, PorterDuff.Mode)
overrides tint.
setTintList
in class Drawable
tintList
- Color state list to use for tinting this drawable, or
null
to clear the tintDrawable.setTint(int)
,
Drawable.setTintMode(PorterDuff.Mode)
public void setTintMode(PorterDuff.Mode mode)
Drawable
Defines how this drawable's tint color should be blended into the drawable
before it is drawn to screen. Default tint mode is PorterDuff.Mode#SRC_IN
.
Note: Setting a color filter via
Drawable.setColorFilter(ColorFilter)
or
Drawable.setColorFilter(int, PorterDuff.Mode)
overrides tint.
setTintMode
in class Drawable
mode
- A Porter-Duff blending modeDrawable.setTint(int)
,
Drawable.setTintList(ColorStateList)
public UserIconDrawable bake()
protected void onBoundsChange(Rect bounds)
Drawable
onBoundsChange
in class Drawable
public void invalidateSelf()
Drawable
Drawable.Callback
implementation to have this Drawable
redrawn. Does nothing if there is no Callback attached to the
Drawable.public boolean isStateful()
Drawable
isStateful
in class Drawable
Drawable.setState(int[])
public 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
public int getIntrinsicWidth()
Drawable
Intrinsic width is the width at which the drawable would like to be laid out, including any inherent padding. If the drawable has no intrinsic width, such as a solid color, this method returns -1.
getIntrinsicWidth
in class Drawable
public int getIntrinsicHeight()
Drawable
Intrinsic height is the height at which the drawable would like to be laid out, including any inherent padding. If the drawable has no intrinsic height, such as a solid color, this method returns -1.
getIntrinsicHeight
in class Drawable
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.