# IconCompat

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

*** ** * ** ***

<br />

```
public class IconCompat implements VersionedParcelable
```

<br />

*** ** * ** ***

Helper for accessing features in `https://developer.android.com/reference/android/graphics/drawable/Icon.html`.

## Summary

| ### Constants |
|---|---|
| `static final int` | `https://developer.android.com/reference/androidx/core/graphics/drawable/IconCompat#TYPE_ADAPTIVE_BITMAP() = 5` An icon that was created using `https://developer.android.com/reference/androidx/core/graphics/drawable/IconCompat#createWithAdaptiveBitmap(android.graphics.Bitmap)`. |
| `static final int` | `https://developer.android.com/reference/androidx/core/graphics/drawable/IconCompat#TYPE_BITMAP() = 1` An icon that was created using `https://developer.android.com/reference/androidx/core/graphics/drawable/IconCompat#createWithBitmap(android.graphics.Bitmap)`. |
| `static final int` | `https://developer.android.com/reference/androidx/core/graphics/drawable/IconCompat#TYPE_DATA() = 3` An icon that was created using `https://developer.android.com/reference/androidx/core/graphics/drawable/IconCompat#createWithData(byte[],int,int)`. |
| `static final int` | `https://developer.android.com/reference/androidx/core/graphics/drawable/IconCompat#TYPE_RESOURCE() = 2` An icon that was created using `https://developer.android.com/reference/androidx/core/graphics/drawable/IconCompat#createWithResource(android.content.Context,int)`. |
| `static final int` | `https://developer.android.com/reference/androidx/core/graphics/drawable/IconCompat#TYPE_UNKNOWN() = -1` Value returned when the type of an `https://developer.android.com/reference/android/graphics/drawable/Icon.html` cannot be determined. |
| `static final int` | `https://developer.android.com/reference/androidx/core/graphics/drawable/IconCompat#TYPE_URI() = 4` An icon that was created using `https://developer.android.com/reference/androidx/core/graphics/drawable/IconCompat#createWithContentUri(java.lang.String)`. |
| `static final int` | `https://developer.android.com/reference/androidx/core/graphics/drawable/IconCompat#TYPE_URI_ADAPTIVE_BITMAP() = 6` An icon that was created using `https://developer.android.com/reference/androidx/core/graphics/drawable/IconCompat#createWithAdaptiveBitmapContentUri(java.lang.String)`. |

| ### Public methods |
|---|---|
| `static @https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/androidx/core/graphics/drawable/IconCompat` | `https://developer.android.com/reference/androidx/core/graphics/drawable/IconCompat#createFromBundle(android.os.Bundle)(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/os/Bundle.html bundle)` Extracts an icon from a bundle that was added using `https://developer.android.com/reference/androidx/core/graphics/drawable/IconCompat#toBundle()`. |
| `static @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/core/graphics/drawable/IconCompat` | `https://developer.android.com/reference/androidx/core/graphics/drawable/IconCompat#createFromIcon(android.content.Context,android.graphics.drawable.Icon)(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/content/Context.html context, @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/graphics/drawable/Icon.html icon)` Creates an IconCompat from an Icon. |
| `static @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/core/graphics/drawable/IconCompat` | `https://developer.android.com/reference/androidx/core/graphics/drawable/IconCompat#createWithAdaptiveBitmap(android.graphics.Bitmap)(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/graphics/Bitmap.html bits)` Create an Icon pointing to a bitmap in memory that follows the icon design guideline defined by `https://developer.android.com/reference/android/graphics/drawable/AdaptiveIconDrawable.html`. |
| `static @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/core/graphics/drawable/IconCompat` | `https://developer.android.com/reference/androidx/core/graphics/drawable/IconCompat#createWithAdaptiveBitmapContentUri(java.lang.String)(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/lang/String.html uri)` Create an Icon pointing to an image file specified by URI. |
| `static @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/core/graphics/drawable/IconCompat` | `https://developer.android.com/reference/androidx/core/graphics/drawable/IconCompat#createWithAdaptiveBitmapContentUri(android.net.Uri)(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/net/Uri.html uri)` Create an Icon pointing to an image file specified by URI. |
| `static @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/core/graphics/drawable/IconCompat` | `https://developer.android.com/reference/androidx/core/graphics/drawable/IconCompat#createWithBitmap(android.graphics.Bitmap)(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/graphics/Bitmap.html bits)` Create an Icon pointing to a bitmap in memory. |
| `static @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/core/graphics/drawable/IconCompat` | `https://developer.android.com/reference/androidx/core/graphics/drawable/IconCompat#createWithContentUri(java.lang.String)(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/lang/String.html uri)` Create an Icon pointing to an image file specified by URI. |
| `static @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/core/graphics/drawable/IconCompat` | `https://developer.android.com/reference/androidx/core/graphics/drawable/IconCompat#createWithContentUri(android.net.Uri)(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/net/Uri.html uri)` Create an Icon pointing to an image file specified by URI. |
| `static @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/core/graphics/drawable/IconCompat` | `https://developer.android.com/reference/androidx/core/graphics/drawable/IconCompat#createWithData(byte[],int,int)(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html byte[] data, int offset, int length)` Create an Icon pointing to a compressed bitmap stored in a byte array. |
| `static @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/core/graphics/drawable/IconCompat` | `https://developer.android.com/reference/androidx/core/graphics/drawable/IconCompat#createWithResource(android.content.Context,int)(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/content/Context.html context, @https://developer.android.com/reference/androidx/annotation/DrawableRes int resId)` Create an Icon pointing to a drawable resource. |
| `@https://developer.android.com/reference/androidx/annotation/DrawableRes int` | `https://developer.android.com/reference/androidx/core/graphics/drawable/IconCompat#getResId()()` Gets the drawable resource id used to create this icon. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/androidx/core/graphics/drawable/IconCompat#getResPackage()()` Gets the package used to create this icon. |
| `int` | `https://developer.android.com/reference/androidx/core/graphics/drawable/IconCompat#getType()()` Gets the type of the icon provided. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/net/Uri.html` | `https://developer.android.com/reference/androidx/core/graphics/drawable/IconCompat#getUri()()` Gets the uri used to create this icon. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/android/graphics/drawable/Drawable.html` | `https://developer.android.com/reference/androidx/core/graphics/drawable/IconCompat#loadDrawable(android.content.Context)(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/content/Context.html context)` Returns a Drawable that can be used to draw the image inside this Icon, constructing it if necessary. |
| `void` | `https://developer.android.com/reference/androidx/core/graphics/drawable/IconCompat#onPostParceling()()` Called immediately after this object has been deserialized, can be used to handle any custom fields that cannot be easily annotated. |
| `void` | `https://developer.android.com/reference/androidx/core/graphics/drawable/IconCompat#onPreParceling(boolean)(boolean isStream)` Called immediately before this object is going to be serialized, can be used to handle any custom fields that cannot be easily annotated. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/core/graphics/drawable/IconCompat` | `https://developer.android.com/reference/androidx/core/graphics/drawable/IconCompat#setTint(int)(@https://developer.android.com/reference/androidx/annotation/ColorInt int tint)` Store a color to use whenever this Icon is drawn. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/core/graphics/drawable/IconCompat` | `https://developer.android.com/reference/androidx/core/graphics/drawable/IconCompat#setTintList(android.content.res.ColorStateList)(@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/android/content/res/ColorStateList.html tintList)` Store a color to use whenever this Icon is drawn. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/core/graphics/drawable/IconCompat` | `https://developer.android.com/reference/androidx/core/graphics/drawable/IconCompat#setTintMode(android.graphics.PorterDuff.Mode)(@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/android/graphics/PorterDuff.Mode.html mode)` Store a blending mode to use whenever this Icon is drawn. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/os/Bundle.html` | `https://developer.android.com/reference/androidx/core/graphics/drawable/IconCompat#toBundle()()` Adds this Icon to a Bundle that can be read back with the same parameters to `https://developer.android.com/reference/androidx/core/graphics/drawable/IconCompat#createFromBundle(android.os.Bundle)`. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/graphics/drawable/Icon.html` | `[toIcon](https://developer.android.com/reference/androidx/core/graphics/drawable/IconCompat#toIcon())()` **This method is deprecated.** Use `https://developer.android.com/reference/androidx/core/graphics/drawable/IconCompat#toIcon(android.content.Context)` to generate the `https://developer.android.com/reference/android/graphics/drawable/Icon.html` object. <br /> |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/graphics/drawable/Icon.html` | `https://developer.android.com/reference/androidx/core/graphics/drawable/IconCompat#toIcon(android.content.Context)(@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/android/content/Context.html context)` Convert this compat object to `https://developer.android.com/reference/android/graphics/drawable/Icon.html` object. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/androidx/core/graphics/drawable/IconCompat#toString()()` |

## Constants

### TYPE_ADAPTIVE_BITMAP

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

```
public static final int TYPE_ADAPTIVE_BITMAP = 5
```

An icon that was created using `https://developer.android.com/reference/androidx/core/graphics/drawable/IconCompat#createWithAdaptiveBitmap(android.graphics.Bitmap)`.

### TYPE_BITMAP

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

```
public static final int TYPE_BITMAP = 1
```

An icon that was created using `https://developer.android.com/reference/androidx/core/graphics/drawable/IconCompat#createWithBitmap(android.graphics.Bitmap)`.

### TYPE_DATA

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

```
public static final int TYPE_DATA = 3
```

An icon that was created using `https://developer.android.com/reference/androidx/core/graphics/drawable/IconCompat#createWithData(byte[],int,int)`.

### TYPE_RESOURCE

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

```
public static final int TYPE_RESOURCE = 2
```

An icon that was created using `https://developer.android.com/reference/androidx/core/graphics/drawable/IconCompat#createWithResource(android.content.Context,int)`.

### TYPE_UNKNOWN

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

```
public static final int TYPE_UNKNOWN = -1
```

Value returned when the type of an `https://developer.android.com/reference/android/graphics/drawable/Icon.html` cannot be determined.

### TYPE_URI

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

```
public static final int TYPE_URI = 4
```

An icon that was created using `https://developer.android.com/reference/androidx/core/graphics/drawable/IconCompat#createWithContentUri(java.lang.String)`.

### TYPE_URI_ADAPTIVE_BITMAP

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

```
public static final int TYPE_URI_ADAPTIVE_BITMAP = 6
```

An icon that was created using `https://developer.android.com/reference/androidx/core/graphics/drawable/IconCompat#createWithAdaptiveBitmapContentUri(java.lang.String)`.

## Public methods

### createFromBundle

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

```
public static @Nullable IconCompat createFromBundle(@NonNull Bundle bundle)
```

Extracts an icon from a bundle that was added using `https://developer.android.com/reference/androidx/core/graphics/drawable/IconCompat#toBundle()`.

### createFromIcon

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

```
public static @NonNull IconCompat createFromIcon(@NonNull Context context, @NonNull Icon icon)
```

Creates an IconCompat from an Icon.

### createWithAdaptiveBitmap

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

```
public static @NonNull IconCompat createWithAdaptiveBitmap(@NonNull Bitmap bits)
```

Create an Icon pointing to a bitmap in memory that follows the icon design guideline defined by `https://developer.android.com/reference/android/graphics/drawable/AdaptiveIconDrawable.html`.

| Parameters |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/graphics/Bitmap.html bits` | A valid `https://developer.android.com/reference/android/graphics/Bitmap.html` object |

| See also |
|---|---|
| `https://developer.android.com/reference/android/graphics/drawable/Icon.html#createWithAdaptiveBitmap(android.graphics.Bitmap)` |   |

### createWithAdaptiveBitmapContentUri

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

```
public static @NonNull IconCompat createWithAdaptiveBitmapContentUri(@NonNull String uri)
```

Create an Icon pointing to an image file specified by URI. Image file should follow the icon design guideline defined by `https://developer.android.com/reference/android/graphics/drawable/AdaptiveIconDrawable.html`.

| Parameters |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/lang/String.html uri` | A uri referring to local content:// or file:// image data. |

| See also |
|---|---|
| `https://developer.android.com/reference/android/graphics/drawable/Icon.html#createWithAdaptiveBitmapContentUri(java.lang.String)` |   |

### createWithAdaptiveBitmapContentUri

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

```
public static @NonNull IconCompat createWithAdaptiveBitmapContentUri(@NonNull Uri uri)
```

Create an Icon pointing to an image file specified by URI. Image file should follow the icon design guideline defined by `https://developer.android.com/reference/android/graphics/drawable/AdaptiveIconDrawable.html`.

| Parameters |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/net/Uri.html uri` | A uri referring to local content:// or file:// image data. |

| See also |
|---|---|
| `https://developer.android.com/reference/android/graphics/drawable/Icon.html#createWithAdaptiveBitmapContentUri(java.lang.String)` |   |

### createWithBitmap

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

```
public static @NonNull IconCompat createWithBitmap(@NonNull Bitmap bits)
```

Create an Icon pointing to a bitmap in memory.

| Parameters |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/graphics/Bitmap.html bits` | A valid `https://developer.android.com/reference/android/graphics/Bitmap.html` object |

| See also |
|---|---|
| `https://developer.android.com/reference/android/graphics/drawable/Icon.html#createWithBitmap(android.graphics.Bitmap)` |   |

### createWithContentUri

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

```
public static @NonNull IconCompat createWithContentUri(@NonNull String uri)
```

Create an Icon pointing to an image file specified by URI.

| Parameters |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/lang/String.html uri` | A uri referring to local content:// or file:// image data. |

| See also |
|---|---|
| `https://developer.android.com/reference/android/graphics/drawable/Icon.html#createWithContentUri(java.lang.String)` |   |

### createWithContentUri

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

```
public static @NonNull IconCompat createWithContentUri(@NonNull Uri uri)
```

Create an Icon pointing to an image file specified by URI.

| Parameters |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/net/Uri.html uri` | A uri referring to local content:// or file:// image data. |

| See also |
|---|---|
| `https://developer.android.com/reference/android/graphics/drawable/Icon.html#createWithContentUri(java.lang.String)` |   |

### createWithData

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

```
public static @NonNull IconCompat createWithData(@NonNull byte[] data, int offset, int length)
```

Create an Icon pointing to a compressed bitmap stored in a byte array.

| Parameters |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html byte[] data` | Byte array storing compressed bitmap data of a type that `https://developer.android.com/reference/android/graphics/BitmapFactory.html` can decode (see `https://developer.android.com/reference/android/graphics/Bitmap.CompressFormat.html`). |
| `int offset` | Offset into `data` at which the bitmap data starts |
| `int length` | Length of the bitmap data |

| See also |
|---|---|
| `https://developer.android.com/reference/android/graphics/drawable/Icon.html#createWithData(byte[], int, int)` |   |

### createWithResource

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

```
public static @NonNull IconCompat createWithResource(@NonNull Context context, @DrawableRes int resId)
```

Create an Icon pointing to a drawable resource.

| Parameters |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/content/Context.html context` | The context for the application whose resources should be used to resolve the given resource ID. |
| `@https://developer.android.com/reference/androidx/annotation/DrawableRes int resId` | ID of the drawable resource |

| See also |
|---|---|
| `https://developer.android.com/reference/android/graphics/drawable/Icon.html#createWithResource(android.content.Context, int)` |   |

### getResId

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

```
public @DrawableRes int getResId()
```

Gets the drawable resource id used to create this icon.

Only valid for icons of type TYPE_RESOURCE. Note: This resource may not be available if the application changes at all, and it is up to the caller to ensure safety if this resource is re-used and/or persisted.

### getResPackage

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

```
public @NonNull String getResPackage()
```

Gets the package used to create this icon.

Only valid for icons of type TYPE_RESOURCE. Note: This package may not be available if referenced in the future, and it is up to the caller to ensure safety if this package is re-used and/or persisted.

### getType

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

```
public int getType()
```

Gets the type of the icon provided.

Note that new types may be added later, so callers should guard against other types being returned.

### getUri

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

```
public @NonNull Uri getUri()
```

Gets the uri used to create this icon.

Only valid for icons of type TYPE_URI. Note: This uri may not be available in the future, and it is up to the caller to ensure safety if this uri is re-used and/or persisted.

### loadDrawable

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

```
public @Nullable Drawable loadDrawable(@NonNull Context context)
```

Returns a Drawable that can be used to draw the image inside this Icon, constructing it if necessary.

| Parameters |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/content/Context.html context` | `https://developer.android.com/reference/android/content/Context.html` in which to load the drawable; used to access `https://developer.android.com/reference/android/content/res/Resources.html`, for example. |

| Returns |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/android/graphics/drawable/Drawable.html` | A fresh instance of a drawable for this image, yours to keep. |

### onPostParceling

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

```
public void onPostParceling()
```

Called immediately after this object has been deserialized, can be used to handle any custom fields that cannot be easily annotated.

### onPreParceling

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

```
public void onPreParceling(boolean isStream)
```

Called immediately before this object is going to be serialized, can be used to handle any custom fields that cannot be easily annotated.

### setTint

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

```
public @NonNull IconCompat setTint(@ColorInt int tint)
```

Store a color to use whenever this Icon is drawn.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/ColorInt int tint` | a color, as in `https://developer.android.com/reference/android/graphics/drawable/Drawable.html#setTint(int)` |

| Returns |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/core/graphics/drawable/IconCompat` | this same object, for use in chained construction |

### setTintList

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

```
public @NonNull IconCompat setTintList(@Nullable ColorStateList tintList)
```

Store a color to use whenever this Icon is drawn.

| Parameters |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/android/content/res/ColorStateList.html tintList` | as in `https://developer.android.com/reference/android/graphics/drawable/Drawable.html#setTintList(android.content.res.ColorStateList)`, null to remove tint |

| Returns |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/core/graphics/drawable/IconCompat` | this same object, for use in chained construction |

### setTintMode

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

```
public @NonNull IconCompat setTintMode(@Nullable PorterDuff.Mode mode)
```

Store a blending mode to use whenever this Icon is drawn.

| Parameters |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/android/graphics/PorterDuff.Mode.html mode` | a blending mode, as in `https://developer.android.com/reference/android/graphics/drawable/Drawable.html#setTintMode(android.graphics.PorterDuff.Mode)`, may be null |

| Returns |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/core/graphics/drawable/IconCompat` | this same object, for use in chained construction |

### toBundle

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

```
public @NonNull Bundle toBundle()
```

Adds this Icon to a Bundle that can be read back with the same parameters to `https://developer.android.com/reference/androidx/core/graphics/drawable/IconCompat#createFromBundle(android.os.Bundle)`.

### toIcon

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

```
public @NonNull Icon [toIcon](https://developer.android.com/reference/androidx/core/graphics/drawable/IconCompat#toIcon())()
```

> [!CAUTION]
> **This method is deprecated.**   
>
> Use `https://developer.android.com/reference/androidx/core/graphics/drawable/IconCompat#toIcon(android.content.Context)` to generate the `https://developer.android.com/reference/android/graphics/drawable/Icon.html` object.

### toIcon

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

```
public @NonNull Icon toIcon(@Nullable Context context)
```

Convert this compat object to `https://developer.android.com/reference/android/graphics/drawable/Icon.html` object.

| Returns |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/graphics/drawable/Icon.html` | `https://developer.android.com/reference/android/graphics/drawable/Icon.html` object |

### toString

```
public @NonNull String toString()
```