# CompositeDrawable

Artifact: [androidx.leanback:leanback](https://developer.android.com/jetpack/androidx/releases/leanback) [View Source](https://cs.android.com/search?q=file:androidx/leanback/graphics/CompositeDrawable.java+class:androidx.leanback.graphics.CompositeDrawable) Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/leanback#1.1.0)

*** ** * ** ***


```
public class CompositeDrawable extends Drawable implements Drawable.Callback
```

<br />

|---|---|---|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object.html) |||
| ↳ | [android.graphics.drawable.Drawable](https://developer.android.com/reference/android/graphics/drawable/Drawable.html) ||
|   | ↳ | [androidx.leanback.graphics.CompositeDrawable](https://developer.android.com/reference/androidx/leanback/graphics/CompositeDrawable) |

*** ** * ** ***

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 |
|---|
| `public final class https://developer.android.com/reference/androidx/leanback/graphics/CompositeDrawable.ChildDrawable` Wrapper class holding a drawable object and `https://developer.android.com/reference/androidx/leanback/graphics/BoundsRule` to update drawable bounds when parent bound changes. |

| ### Public constructors |
|---|
| `https://developer.android.com/reference/androidx/leanback/graphics/CompositeDrawable#CompositeDrawable()()` |

| ### Public methods |
|---|---|
| `void` | `https://developer.android.com/reference/androidx/leanback/graphics/CompositeDrawable#addChildDrawable(android.graphics.drawable.Drawable)(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/graphics/drawable/Drawable.html drawable)` Adds the supplied region. |
| `void` | `https://developer.android.com/reference/androidx/leanback/graphics/CompositeDrawable#draw(android.graphics.Canvas)(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/graphics/Canvas.html canvas)` |
| `int` | `https://developer.android.com/reference/androidx/leanback/graphics/CompositeDrawable#getAlpha()()` |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/leanback/graphics/CompositeDrawable.ChildDrawable` | `https://developer.android.com/reference/androidx/leanback/graphics/CompositeDrawable#getChildAt(int)(int index)` Returns the `https://developer.android.com/reference/androidx/leanback/graphics/CompositeDrawable.ChildDrawable` at the given index. |
| `int` | `https://developer.android.com/reference/androidx/leanback/graphics/CompositeDrawable#getChildCount()()` Returns the total number of children. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/graphics/drawable/Drawable.ConstantState.html` | `https://developer.android.com/reference/androidx/leanback/graphics/CompositeDrawable#getConstantState()()` |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/graphics/drawable/Drawable.html` | `https://developer.android.com/reference/androidx/leanback/graphics/CompositeDrawable#getDrawable(int)(int index)` Returns the `https://developer.android.com/reference/android/graphics/drawable/Drawable.html` for the given index. |
| `int` | `https://developer.android.com/reference/androidx/leanback/graphics/CompositeDrawable#getOpacity()()` **This method is deprecated.** |
| `void` | `https://developer.android.com/reference/androidx/leanback/graphics/CompositeDrawable#invalidateDrawable(android.graphics.drawable.Drawable)(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/graphics/drawable/Drawable.html who)` |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/graphics/drawable/Drawable.html` | `https://developer.android.com/reference/androidx/leanback/graphics/CompositeDrawable#mutate()()` |
| `void` | `https://developer.android.com/reference/androidx/leanback/graphics/CompositeDrawable#removeChild(int)(int index)` Removes the child corresponding to the given index. |
| `void` | `https://developer.android.com/reference/androidx/leanback/graphics/CompositeDrawable#removeDrawable(android.graphics.drawable.Drawable)(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/graphics/drawable/Drawable.html drawable)` Removes the given region. |
| `void` | `https://developer.android.com/reference/androidx/leanback/graphics/CompositeDrawable#scheduleDrawable(android.graphics.drawable.Drawable,java.lang.Runnable,long)(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/graphics/drawable/Drawable.html who, @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/lang/Runnable.html what, long when)` |
| `void` | `https://developer.android.com/reference/androidx/leanback/graphics/CompositeDrawable#setAlpha(int)(int alpha)` |
| `void` | `https://developer.android.com/reference/androidx/leanback/graphics/CompositeDrawable#setChildDrawableAt(int,android.graphics.drawable.Drawable)(int index, @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/graphics/drawable/Drawable.html drawable)` Sets the supplied region at given index. |
| `void` | `https://developer.android.com/reference/androidx/leanback/graphics/CompositeDrawable#setColorFilter(android.graphics.ColorFilter)(@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/android/graphics/ColorFilter.html colorFilter)` |
| `void` | `https://developer.android.com/reference/androidx/leanback/graphics/CompositeDrawable#unscheduleDrawable(android.graphics.drawable.Drawable,java.lang.Runnable)(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/graphics/drawable/Drawable.html who, @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/lang/Runnable.html what)` |

| ### Protected methods |
|---|---|
| `void` | `https://developer.android.com/reference/androidx/leanback/graphics/CompositeDrawable#onBoundsChange(android.graphics.Rect)(https://developer.android.com/reference/android/graphics/Rect.html bounds)` |

| ### Inherited methods |
|---|
| From [android.graphics.drawable.Drawable](https://developer.android.com/reference/android/graphics/drawable/Drawable.html) |---|---| | `void` | `https://developer.android.com/reference/android/graphics/drawable/Drawable.html#applyTheme(android.content.res.Resources.Theme)(https://developer.android.com/reference/android/content/res/Resources.Theme.html t)` | | `boolean` | `https://developer.android.com/reference/android/graphics/drawable/Drawable.html#canApplyTheme()()` | | `void` | `https://developer.android.com/reference/android/graphics/drawable/Drawable.html#clearColorFilter()()` | | `final https://developer.android.com/reference/android/graphics/Rect.html` | `https://developer.android.com/reference/android/graphics/drawable/Drawable.html#copyBounds()()` | | `final void` | `https://developer.android.com/reference/android/graphics/drawable/Drawable.html#copyBounds(android.graphics.Rect)(https://developer.android.com/reference/android/graphics/Rect.html bounds)` | | `static https://developer.android.com/reference/android/graphics/drawable/Drawable.html` | `https://developer.android.com/reference/android/graphics/drawable/Drawable.html#createFromPath(java.lang.String)(https://developer.android.com/reference/java/lang/String.html pathName)` | | `static https://developer.android.com/reference/android/graphics/drawable/Drawable.html` | `https://developer.android.com/reference/android/graphics/drawable/Drawable.html#createFromResourceStream(android.content.res.Resources, android.util.TypedValue, java.io.InputStream, java.lang.String)( https://developer.android.com/reference/android/content/res/Resources.html res, https://developer.android.com/reference/android/util/TypedValue.html value, https://developer.android.com/reference/java/io/InputStream.html is, https://developer.android.com/reference/java/lang/String.html srcName )` | | `static https://developer.android.com/reference/android/graphics/drawable/Drawable.html` | `https://developer.android.com/reference/android/graphics/drawable/Drawable.html#createFromStream(java.io.InputStream, java.lang.String)(https://developer.android.com/reference/java/io/InputStream.html is, https://developer.android.com/reference/java/lang/String.html srcName)` | | `static https://developer.android.com/reference/android/graphics/drawable/Drawable.html` | `https://developer.android.com/reference/android/graphics/drawable/Drawable.html#createFromXml(android.content.res.Resources, org.xmlpull.v1.XmlPullParser)(https://developer.android.com/reference/android/content/res/Resources.html r, https://developer.android.com/reference/org/xmlpull/v1/XmlPullParser.html parser)` | | `static https://developer.android.com/reference/android/graphics/drawable/Drawable.html` | `https://developer.android.com/reference/android/graphics/drawable/Drawable.html#createFromXmlInner(android.content.res.Resources, org.xmlpull.v1.XmlPullParser, android.util.AttributeSet)( https://developer.android.com/reference/android/content/res/Resources.html r, https://developer.android.com/reference/org/xmlpull/v1/XmlPullParser.html parser, https://developer.android.com/reference/android/util/AttributeSet.html attrs )` | | `final https://developer.android.com/reference/android/graphics/Rect.html` | `https://developer.android.com/reference/android/graphics/drawable/Drawable.html#getBounds()()` | | `https://developer.android.com/reference/android/graphics/drawable/Drawable.Callback.html` | `https://developer.android.com/reference/android/graphics/drawable/Drawable.html#getCallback()()` | | `int` | `https://developer.android.com/reference/android/graphics/drawable/Drawable.html#getChangingConfigurations()()` | | `https://developer.android.com/reference/android/graphics/ColorFilter.html` | `https://developer.android.com/reference/android/graphics/drawable/Drawable.html#getColorFilter()()` | | `https://developer.android.com/reference/android/graphics/drawable/Drawable.html` | `https://developer.android.com/reference/android/graphics/drawable/Drawable.html#getCurrent()()` | | `https://developer.android.com/reference/android/graphics/Rect.html` | `https://developer.android.com/reference/android/graphics/drawable/Drawable.html#getDirtyBounds()()` | | `void` | `https://developer.android.com/reference/android/graphics/drawable/Drawable.html#getHotspotBounds(android.graphics.Rect)(https://developer.android.com/reference/android/graphics/Rect.html outRect)` | | `int` | `https://developer.android.com/reference/android/graphics/drawable/Drawable.html#getIntrinsicHeight()()` | | `int` | `https://developer.android.com/reference/android/graphics/drawable/Drawable.html#getIntrinsicWidth()()` | | `int` | `https://developer.android.com/reference/android/graphics/drawable/Drawable.html#getLayoutDirection()()` | | `final int` | `https://developer.android.com/reference/android/graphics/drawable/Drawable.html#getLevel()()` | | `int` | `https://developer.android.com/reference/android/graphics/drawable/Drawable.html#getMinimumHeight()()` | | `int` | `https://developer.android.com/reference/android/graphics/drawable/Drawable.html#getMinimumWidth()()` | | `https://developer.android.com/reference/android/graphics/Insets.html` | `https://developer.android.com/reference/android/graphics/drawable/Drawable.html#getOpticalInsets()()` | | `void` | `https://developer.android.com/reference/android/graphics/drawable/Drawable.html#getOutline(android.graphics.Outline)(https://developer.android.com/reference/android/graphics/Outline.html outline)` | | `boolean` | `https://developer.android.com/reference/android/graphics/drawable/Drawable.html#getPadding(android.graphics.Rect)(https://developer.android.com/reference/android/graphics/Rect.html padding)` | | `int[]` | `https://developer.android.com/reference/android/graphics/drawable/Drawable.html#getState()()` | | `https://developer.android.com/reference/android/graphics/Region.html` | `https://developer.android.com/reference/android/graphics/drawable/Drawable.html#getTransparentRegion()()` | | `boolean` | `https://developer.android.com/reference/android/graphics/drawable/Drawable.html#hasFocusStateSpecified()()` | | `void` | `https://developer.android.com/reference/android/graphics/drawable/Drawable.html#inflate(android.content.res.Resources, org.xmlpull.v1.XmlPullParser, android.util.AttributeSet)(https://developer.android.com/reference/android/content/res/Resources.html r, https://developer.android.com/reference/org/xmlpull/v1/XmlPullParser.html parser, https://developer.android.com/reference/android/util/AttributeSet.html attrs)` | | `void` | `https://developer.android.com/reference/android/graphics/drawable/Drawable.html#invalidateSelf()()` | | `boolean` | `https://developer.android.com/reference/android/graphics/drawable/Drawable.html#isAutoMirrored()()` | | `boolean` | `https://developer.android.com/reference/android/graphics/drawable/Drawable.html#isFilterBitmap()()` | | `boolean` | `https://developer.android.com/reference/android/graphics/drawable/Drawable.html#isProjected()()` | | `boolean` | `https://developer.android.com/reference/android/graphics/drawable/Drawable.html#isStateful()()` | | `final boolean` | `https://developer.android.com/reference/android/graphics/drawable/Drawable.html#isVisible()()` | | `void` | `https://developer.android.com/reference/android/graphics/drawable/Drawable.html#jumpToCurrentState()()` | | `boolean` | `https://developer.android.com/reference/android/graphics/drawable/Drawable.html#onLayoutDirectionChanged(int)(int layoutDirection)` | | `boolean` | `https://developer.android.com/reference/android/graphics/drawable/Drawable.html#onLevelChange(int)(int level)` | | `boolean` | `https://developer.android.com/reference/android/graphics/drawable/Drawable.html#onStateChange(int[])(int[] state)` | | `static int` | `https://developer.android.com/reference/android/graphics/drawable/Drawable.html#resolveOpacity(int, int)(int op1, int op2)` | | `void` | `https://developer.android.com/reference/android/graphics/drawable/Drawable.html#scheduleSelf(java.lang.Runnable, long)(https://developer.android.com/reference/java/lang/Runnable.html what, long when)` | | `void` | `https://developer.android.com/reference/android/graphics/drawable/Drawable.html#setAutoMirrored(boolean)(boolean mirrored)` | | `void` | `https://developer.android.com/reference/android/graphics/drawable/Drawable.html#setBounds(android.graphics.Rect)(https://developer.android.com/reference/android/graphics/Rect.html bounds)` | | `final void` | `https://developer.android.com/reference/android/graphics/drawable/Drawable.html#setCallback(android.graphics.drawable.Drawable.Callback)(https://developer.android.com/reference/android/graphics/drawable/Drawable.Callback.html cb)` | | `void` | `https://developer.android.com/reference/android/graphics/drawable/Drawable.html#setChangingConfigurations(int)(int configs)` | | `void` | `https://developer.android.com/reference/android/graphics/drawable/Drawable.html#setDither(boolean)(boolean dither)` **This method is deprecated.** | | `void` | `https://developer.android.com/reference/android/graphics/drawable/Drawable.html#setFilterBitmap(boolean)(boolean filter)` | | `void` | `https://developer.android.com/reference/android/graphics/drawable/Drawable.html#setHotspot(float, float)(float x, float y)` | | `void` | `https://developer.android.com/reference/android/graphics/drawable/Drawable.html#setHotspotBounds(int, int, int, int)(int left, int top, int right, int bottom)` | | `final boolean` | `https://developer.android.com/reference/android/graphics/drawable/Drawable.html#setLayoutDirection(int)(int layoutDirection)` | | `final boolean` | `https://developer.android.com/reference/android/graphics/drawable/Drawable.html#setLevel(int)(int level)` | | `boolean` | `https://developer.android.com/reference/android/graphics/drawable/Drawable.html#setState(int[])(int[] stateSet)` | | `void` | `https://developer.android.com/reference/android/graphics/drawable/Drawable.html#setTint(int)(int tintColor)` | | `void` | `https://developer.android.com/reference/android/graphics/drawable/Drawable.html#setTintBlendMode(android.graphics.BlendMode)(https://developer.android.com/reference/android/graphics/BlendMode.html blendMode)` | | `void` | `https://developer.android.com/reference/android/graphics/drawable/Drawable.html#setTintList(android.content.res.ColorStateList)(https://developer.android.com/reference/android/content/res/ColorStateList.html tint)` | | `void` | `https://developer.android.com/reference/android/graphics/drawable/Drawable.html#setTintMode(android.graphics.PorterDuff.Mode)(https://developer.android.com/reference/android/graphics/PorterDuff.Mode.html tintMode)` | | `boolean` | `https://developer.android.com/reference/android/graphics/drawable/Drawable.html#setVisible(boolean, boolean)(boolean visible, boolean restart)` | | `void` | `https://developer.android.com/reference/android/graphics/drawable/Drawable.html#unscheduleSelf(java.lang.Runnable)(https://developer.android.com/reference/java/lang/Runnable.html what)` | |

## Public constructors

### CompositeDrawable

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/leanback#1.1.0)

```
public CompositeDrawable()
```

## Public methods

### addChildDrawable

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/leanback#1.1.0)

```
public void addChildDrawable(@NonNull Drawable drawable)
```

Adds the supplied region.

### draw

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/leanback#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](https://developer.android.com/jetpack/androidx/releases/leanback#1.1.0)

```
public @NonNull CompositeDrawable.ChildDrawable getChildAt(int index)
```

Returns the `https://developer.android.com/reference/androidx/leanback/graphics/CompositeDrawable.ChildDrawable` at the given index.

### getChildCount

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/leanback#1.1.0)

```
public int getChildCount()
```

Returns the total number of children.

### getConstantState

```
public @NonNull Drawable.ConstantState getConstantState()
```

### getDrawable

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/leanback#1.1.0)

```
public @NonNull Drawable getDrawable(int index)
```

Returns the `https://developer.android.com/reference/android/graphics/drawable/Drawable.html` for the given index.

### getOpacity

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/leanback#1.1.0)

```
public int getOpacity()
```

> [!CAUTION]
> **This method is deprecated.**   

### invalidateDrawable

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/leanback#1.1.0)

```
public void invalidateDrawable(@NonNull Drawable who)
```

### mutate

```
public @NonNull Drawable mutate()
```

### removeChild

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/leanback#1.1.0)

```
public void removeChild(int index)
```

Removes the child corresponding to the given index.

### removeDrawable

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/leanback#1.1.0)

```
public void removeDrawable(@NonNull Drawable drawable)
```

Removes the given region.

### scheduleDrawable

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/leanback#1.1.0)

```
public void scheduleDrawable(@NonNull Drawable who, @NonNull Runnable what, long when)
```

### setAlpha

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/leanback#1.1.0)

```
public void setAlpha(int alpha)
```

### setChildDrawableAt

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/leanback#1.1.0)

```
public void setChildDrawableAt(int index, @NonNull Drawable drawable)
```

Sets the supplied region at given index.

### setColorFilter

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/leanback#1.1.0)

```
public void setColorFilter(@Nullable ColorFilter colorFilter)
```

### unscheduleDrawable

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/leanback#1.1.0)

```
public void unscheduleDrawable(@NonNull Drawable who, @NonNull Runnable what)
```

## Protected methods

### onBoundsChange

```
protected void onBoundsChange(Rect bounds)
```