# IconCompat

added in[version 26.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  
belongs to Maven artifact com.android.support:support-compat:28.0.0-alpha1  
Summary:[Methods](https://developer.android.com/reference/android/support/v4/graphics/drawable/IconCompat#pubmethods)\|[Inherited Methods](https://developer.android.com/reference/android/support/v4/graphics/drawable/IconCompat#inhmethods)\|[\[Expand All\]](https://developer.android.com/reference/android/support/v4/graphics/drawable/IconCompat#)  

# IconCompat

| This package is part of the Android[support library](https://developer.android.com/topic/libraries/support-library)which is no longer maintained. The support library has been superseded by[AndroidX](https://developer.android.com/jetpack/androidx)which is part of[Jetpack](https://developer.android.com/jetpack). We recommend using the AndroidX libraries in all new projects. You should also consider[migrating](https://developer.android.com/jetpack/androidx/migrate)existing projects to AndroidX. To find the AndroidX class that maps to this deprecated class, see the AndroidX support library[class mappings](https://developer.android.com/jetpack/androidx/migrate/class-mappings).

`
public


class
IconCompat
`  
`

extends Object


``


`

|---|-------------------------------------------------|
| java.lang.Object                                   ||
| ↳ | android.support.v4.graphics.drawable.IconCompat |

<br />

*** ** * ** ***

Helper for accessing features in[Icon](https://developer.android.com/reference/android/graphics/drawable/Icon.html).

## Summary

|                                                                                                                                                                                                                                                                                           ### Public methods                                                                                                                                                                                                                                                                                            ||
|-----------------------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| ` static `[IconCompat](https://developer.android.com/reference/android/support/v4/graphics/drawable/IconCompat) | ` `[createWithAdaptiveBitmap](https://developer.android.com/reference/android/support/v4/graphics/drawable/IconCompat#createWithAdaptiveBitmap(android.graphics.Bitmap))`(`[Bitmap](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[AdaptiveIconDrawable](https://developer.android.com/reference/android/graphics/drawable/AdaptiveIconDrawable.html). |
| ` static `[IconCompat](https://developer.android.com/reference/android/support/v4/graphics/drawable/IconCompat) | ` `[createWithBitmap](https://developer.android.com/reference/android/support/v4/graphics/drawable/IconCompat#createWithBitmap(android.graphics.Bitmap))`(`[Bitmap](https://developer.android.com/reference/android/graphics/Bitmap.html)` bits) ` Create an Icon pointing to a bitmap in memory.                                                                                                                                                                                      |
| ` static `[IconCompat](https://developer.android.com/reference/android/support/v4/graphics/drawable/IconCompat) | ` `[createWithContentUri](https://developer.android.com/reference/android/support/v4/graphics/drawable/IconCompat#createWithContentUri(java.lang.String))`(String uri) ` Create an Icon pointing to an image file specified by URI.                                                                                                                                                                                                                                                    |
| ` static `[IconCompat](https://developer.android.com/reference/android/support/v4/graphics/drawable/IconCompat) | ` `[createWithContentUri](https://developer.android.com/reference/android/support/v4/graphics/drawable/IconCompat#createWithContentUri(android.net.Uri))`(`[Uri](https://developer.android.com/reference/android/net/Uri.html)` uri) ` Create an Icon pointing to an image file specified by URI.                                                                                                                                                                                      |
| ` static `[IconCompat](https://developer.android.com/reference/android/support/v4/graphics/drawable/IconCompat) | ` `[createWithData](https://developer.android.com/reference/android/support/v4/graphics/drawable/IconCompat#createWithData(byte[], int, int))`(byte[] data, int offset, int length) ` Create an Icon pointing to a compressed bitmap stored in a byte array.                                                                                                                                                                                                                           |
| ` static `[IconCompat](https://developer.android.com/reference/android/support/v4/graphics/drawable/IconCompat) | ` `[createWithResource](https://developer.android.com/reference/android/support/v4/graphics/drawable/IconCompat#createWithResource(android.content.Context, int))`(`[Context](https://developer.android.com/reference/android/content/Context.html)` context, int resId) ` Create an Icon pointing to a drawable resource.                                                                                                                                                             |
| ` `[Icon](https://developer.android.com/reference/android/graphics/drawable/Icon.html)                          | ` `[toIcon](https://developer.android.com/reference/android/support/v4/graphics/drawable/IconCompat#toIcon())`() ` Convert this compat object to[Icon](https://developer.android.com/reference/android/graphics/drawable/Icon.html)object.                                                                                                                                                                                                                                             |

| ### Inherited methods |
|-----------------------|---|
| [![](https://developer.android.com/static/assets/images/styles/disclosure_down.png)](https://developer.android.com/reference/android/support/v4/graphics/drawable/IconCompat#)From class` java.lang.Object ` |-------------------|-------------------------------| | ` Object`         | ` clone() `                   | | ` boolean`        | ` equals(Object arg0) `       | | ` void`           | ` finalize() `                | | ` final Class<?>` | ` getClass() `                | | ` int`            | ` hashCode() `                | | ` final void`     | ` notify() `                  | | ` final void`     | ` notifyAll() `               | | ` String`         | ` toString() `                | | ` final void`     | ` wait(long arg0, int arg1) ` | | ` final void`     | ` wait(long arg0) `           | | ` final void`     | ` wait() `                    | ||

## Public methods

### createWithAdaptiveBitmap

added in[version 26.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
IconCompat createWithAdaptiveBitmap (Bitmap bits)
```

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

<br />

|                                                      Parameters                                                      ||
|--------|--------------------------------------------------------------------------------------------------------------|
| `bits` | `Bitmap`: A valid[Bitmap](https://developer.android.com/reference/android/graphics/Bitmap.html)object <br /> |

|                                                    Returns                                                    ||
|-------------------------------------------------------------------------------------------------------|--------|
| [IconCompat](https://developer.android.com/reference/android/support/v4/graphics/drawable/IconCompat) | <br /> |

**See also:**

- [createWithAdaptiveBitmap(Bitmap)](https://developer.android.com/https://developer.android.com/reference/android/graphics/drawable/Icon#createWithAdaptiveBitmap(android.graphics.Bitmap))  

### createWithBitmap

added in[version 26.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
IconCompat createWithBitmap (Bitmap bits)
```

Create an Icon pointing to a bitmap in memory.

<br />

|                                                      Parameters                                                      ||
|--------|--------------------------------------------------------------------------------------------------------------|
| `bits` | `Bitmap`: A valid[Bitmap](https://developer.android.com/reference/android/graphics/Bitmap.html)object <br /> |

|                                                    Returns                                                    ||
|-------------------------------------------------------------------------------------------------------|--------|
| [IconCompat](https://developer.android.com/reference/android/support/v4/graphics/drawable/IconCompat) | <br /> |

**See also:**

- [createWithBitmap(Bitmap)](https://developer.android.com/https://developer.android.com/reference/android/graphics/drawable/Icon#createWithBitmap(android.graphics.Bitmap))  

### createWithContentUri

added in[version 26.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
IconCompat createWithContentUri (String uri)
```

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

<br />

|                                     Parameters                                     ||
|-------|-----------------------------------------------------------------------------|
| `uri` | `String`: A uri referring to local content:// or file:// image data. <br /> |

|                                                    Returns                                                    ||
|-------------------------------------------------------------------------------------------------------|--------|
| [IconCompat](https://developer.android.com/reference/android/support/v4/graphics/drawable/IconCompat) | <br /> |

**See also:**

- [createWithContentUri(String)](https://developer.android.com/https://developer.android.com/reference/android/graphics/drawable/Icon#createWithContentUri(java.lang.String))  

### createWithContentUri

added in[version 26.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
IconCompat createWithContentUri (Uri uri)
```

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

<br />

|                                   Parameters                                    ||
|-------|--------------------------------------------------------------------------|
| `uri` | `Uri`: A uri referring to local content:// or file:// image data. <br /> |

|                                                    Returns                                                    ||
|-------------------------------------------------------------------------------------------------------|--------|
| [IconCompat](https://developer.android.com/reference/android/support/v4/graphics/drawable/IconCompat) | <br /> |

**See also:**

- [createWithContentUri(String)](https://developer.android.com/https://developer.android.com/reference/android/graphics/drawable/Icon#createWithContentUri(java.lang.String))  

### createWithData

added in[version 26.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
IconCompat createWithData (byte[] data, 
                int offset, 
                int length)
```

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

<br />

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

|                                                    Returns                                                    ||
|-------------------------------------------------------------------------------------------------------|--------|
| [IconCompat](https://developer.android.com/reference/android/support/v4/graphics/drawable/IconCompat) | <br /> |

**See also:**

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

### createWithResource

added in[version 26.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
IconCompat createWithResource (Context context, 
                int resId)
```

Create an Icon pointing to a drawable resource.

<br />

|                                                          Parameters                                                           ||
|-----------|--------------------------------------------------------------------------------------------------------------------|
| `context` | `Context`: The context for the application whose resources should be used to resolve the given resource ID. <br /> |
| `resId`   | `int`: ID of the drawable resource <br />                                                                          |

|                                                    Returns                                                    ||
|-------------------------------------------------------------------------------------------------------|--------|
| [IconCompat](https://developer.android.com/reference/android/support/v4/graphics/drawable/IconCompat) | <br /> |

**See also:**

- [createWithResource(Context, int)](https://developer.android.com/https://developer.android.com/reference/android/graphics/drawable/Icon#createWithResource(android.content.Context, int))  

### toIcon

added in[version 27.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
Icon toIcon ()
```

Convert this compat object to[Icon](https://developer.android.com/reference/android/graphics/drawable/Icon.html)object.

<br />

|                                                                                        Returns                                                                                        ||
|-------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------|
| [Icon](https://developer.android.com/reference/android/graphics/drawable/Icon.html) | [Icon](https://developer.android.com/reference/android/graphics/drawable/Icon.html)object <br /> |

-

  ## Classes

  - [DrawableCompat](https://developer.android.com/reference/android/support/v4/graphics/drawable/DrawableCompat)
  - [IconCompat](https://developer.android.com/reference/android/support/v4/graphics/drawable/IconCompat)
  - [RoundedBitmapDrawable](https://developer.android.com/reference/android/support/v4/graphics/drawable/RoundedBitmapDrawable)
  - [RoundedBitmapDrawableFactory](https://developer.android.com/reference/android/support/v4/graphics/drawable/RoundedBitmapDrawableFactory)