CompositeDrawable

public class CompositeDrawable extends Drawable implements Drawable.Callback


Generic drawable class that can be composed of multiple children. Whenever the bounds changes for this class, it updates those of its children.

Summary

Nested types

Wrapper class holding a drawable object and BoundsRule to update drawable bounds when parent bound changes.

Public constructors

Public methods

void

Adds the supplied region.

void
draw(@NonNull Canvas canvas)
int
@NonNull CompositeDrawable.ChildDrawable
getChildAt(int index)

Returns the ChildDrawable at the given index.

int

Returns the total number of children.

@NonNull Drawable.ConstantState
@NonNull Drawable
getDrawable(int index)

Returns the Drawable for the given index.

int

This method is deprecated.

void
@NonNull Drawable
void
removeChild(int index)

Removes the child corresponding to the given index.

void

Removes the given region.

void
scheduleDrawable(@NonNull Drawable who, @NonNull Runnable what, long when)
void
setAlpha(int alpha)
void
setChildDrawableAt(int index, @NonNull Drawable drawable)

Sets the supplied region at given index.

void
void

Protected methods

void

Inherited methods

From android.graphics.drawable.Drawable
void
boolean
void
final Rect
final void
copyBounds(Rect bounds)
static Drawable
static Drawable
createFromResourceStream(
    Resources res,
    TypedValue value,
    InputStream is,
    String srcName
)
static Drawable
static Drawable
static Drawable
createFromXmlInner(
    Resources r,
    XmlPullParser parser,
    AttributeSet attrs
)
final Rect
Drawable.Callback
int
ColorFilter
Drawable
Rect
void
int
int
int
final int
int
int
Insets
void
boolean
getPadding(Rect padding)
int[]
Region
boolean
void
void
boolean
boolean
boolean
boolean
final boolean
void
boolean
onLayoutDirectionChanged(int layoutDirection)
boolean
onLevelChange(int level)
boolean
onStateChange(int[] state)
static int
resolveOpacity(int op1, int op2)
void
scheduleSelf(Runnable what, long when)
void
setAutoMirrored(boolean mirrored)
void
setBounds(int left, int top, int right, int bottom)
final void
void
void
setDither(boolean dither)

This method is deprecated.

void
setFilterBitmap(boolean filter)
void
setHotspot(float x, float y)
void
setHotspotBounds(int left, int top, int right, int bottom)
final boolean
setLayoutDirection(int layoutDirection)
final boolean
setLevel(int level)
boolean
setState(int[] stateSet)
void
setTint(int tintColor)
void
void
void
boolean
setVisible(boolean visible, boolean restart)
void

Public constructors

CompositeDrawable

Added in 1.1.0
public CompositeDrawable()

Public methods

addChildDrawable

Added in 1.1.0
public void addChildDrawable(@NonNull Drawable drawable)

Adds the supplied region.

draw

Added in 1.1.0
public void draw(@NonNull Canvas canvas)

getAlpha

public int getAlpha()
Returns
int

Alpha value between 0(inclusive) and 255(inclusive)

getChildAt

Added in 1.1.0
public @NonNull CompositeDrawable.ChildDrawable getChildAt(int index)

Returns the ChildDrawable at the given index.

getChildCount

Added in 1.1.0
public int getChildCount()

Returns the total number of children.

getConstantState

public @NonNull Drawable.ConstantState getConstantState()

getDrawable

Added in 1.1.0
public @NonNull Drawable getDrawable(int index)

Returns the Drawable for the given index.

getOpacity

Added in 1.1.0
public int getOpacity()

invalidateDrawable

Added in 1.1.0
public void invalidateDrawable(@NonNull Drawable who)

mutate

public @NonNull Drawable mutate()

removeChild

Added in 1.1.0
public void removeChild(int index)

Removes the child corresponding to the given index.

removeDrawable

Added in 1.1.0
public void removeDrawable(@NonNull Drawable drawable)

Removes the given region.

scheduleDrawable

Added in 1.1.0
public void scheduleDrawable(@NonNull Drawable who, @NonNull Runnable what, long when)

setAlpha

Added in 1.1.0
public void setAlpha(int alpha)

setChildDrawableAt

Added in 1.1.0
public void setChildDrawableAt(int index, @NonNull Drawable drawable)

Sets the supplied region at given index.

setColorFilter

Added in 1.1.0
public void setColorFilter(@Nullable ColorFilter colorFilter)

unscheduleDrawable

Added in 1.1.0
public void unscheduleDrawable(@NonNull Drawable who, @NonNull Runnable what)

Protected methods

onBoundsChange

protected void onBoundsChange(Rect bounds)