Google is committed to advancing racial equity for Black communities. See how.

IconCompat

open class IconCompat : CustomVersionedParcelable
androidx.core.graphics.drawable.IconCompat

Helper for accessing features in android.graphics.drawable.Icon.

Summary

Constants
static Int

An icon that was created using createWithAdaptiveBitmap.

static Int

An icon that was created using createWithBitmap(Bitmap).

static Int

An icon that was created using createWithData(byte[], int, int).

static Int

An icon that was created using #createWithResource.

static Int

Value returned when the type of an Icon cannot be determined.

static Int

An icon that was created using #createWithContentUri.

static Int

An icon that was created using #createWithAdaptiveBitmapContentUri.

Public methods
open static IconCompat?
createFromBundle(@NonNull bundle: Bundle)

Extracts an icon from a bundle that was added using toBundle().

open static IconCompat?
createFromIcon(@NonNull context: Context, @NonNull icon: Icon)

Creates an IconCompat from an Icon.

open static IconCompat!

Create an Icon pointing to a bitmap in memory that follows the icon design guideline defined by android.graphics.drawable.AdaptiveIconDrawable.

open static IconCompat

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

open static IconCompat

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

open static IconCompat!

Create an Icon pointing to a bitmap in memory.

open static IconCompat!

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

open static IconCompat!

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

open static IconCompat!
createWithData(data: ByteArray!, offset: Int, length: Int)

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

open static IconCompat!
createWithResource(context: Context!, @DrawableRes resId: Int)

Create an Icon pointing to a drawable resource.

open Int

Gets the resource id used to create this icon.

open String

Gets the package used to create this icon.

open Int

Gets the type of the icon provided.

open Uri

Gets the uri used to create this icon.

open Drawable?
loadDrawable(@NonNull context: Context)

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

open Unit

open Unit

open IconCompat!
setTint(@ColorInt tint: Int)

Store a color to use whenever this Icon is drawn.

open IconCompat!

Store a color to use whenever this Icon is drawn.

open IconCompat!
setTintMode(mode: Mode!)

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

open Bundle

Adds this Icon to a Bundle that can be read back with the same parameters to createFromBundle(Bundle).

open Icon

open Icon
toIcon(@Nullable context: Context?)

Convert this compat object to Icon object.

open String

Constants

TYPE_ADAPTIVE_BITMAP

static val TYPE_ADAPTIVE_BITMAP: Int

An icon that was created using createWithAdaptiveBitmap.

Value: Icon.TYPE_ADAPTIVE_BITMAP

TYPE_BITMAP

static val TYPE_BITMAP: Int

An icon that was created using createWithBitmap(Bitmap).

Value: Icon.TYPE_BITMAP

TYPE_DATA

static val TYPE_DATA: Int

An icon that was created using createWithData(byte[], int, int).

Value: Icon.TYPE_DATA

TYPE_RESOURCE

static val TYPE_RESOURCE: Int

An icon that was created using #createWithResource.

Value: Icon.TYPE_RESOURCE

TYPE_UNKNOWN

static val TYPE_UNKNOWN: Int

Value returned when the type of an Icon cannot be determined.

Value: -1

TYPE_URI

static val TYPE_URI: Int

An icon that was created using #createWithContentUri.

Value: Icon.TYPE_URI

TYPE_URI_ADAPTIVE_BITMAP

static val TYPE_URI_ADAPTIVE_BITMAP: Int

An icon that was created using #createWithAdaptiveBitmapContentUri.

Value: Icon.TYPE_URI_ADAPTIVE_BITMAP

Public methods

createFromBundle

@Nullable open static fun createFromBundle(@NonNull bundle: Bundle): IconCompat?

Extracts an icon from a bundle that was added using toBundle().

createFromIcon

@RequiresApi(23) @Nullable open static fun createFromIcon(
    @NonNull context: Context,
    @NonNull icon: Icon
): IconCompat?

Creates an IconCompat from an Icon.

createWithAdaptiveBitmap

open static fun createWithAdaptiveBitmap(bits: Bitmap!): IconCompat!

Create an Icon pointing to a bitmap in memory that follows the icon design guideline defined by android.graphics.drawable.AdaptiveIconDrawable.

Parameters
bits Bitmap!: A valid android.graphics.Bitmap object

createWithAdaptiveBitmapContentUri

@NonNull open static fun createWithAdaptiveBitmapContentUri(@NonNull uri: String): IconCompat

Create an Icon pointing to an image file specified by URI. Image file should follow the icon design guideline defined by AdaptiveIconDrawable.

Parameters
uri String: A uri referring to local content:// or file:// image data.

createWithAdaptiveBitmapContentUri

@NonNull open static fun createWithAdaptiveBitmapContentUri(@NonNull uri: Uri): IconCompat

Create an Icon pointing to an image file specified by URI. Image file should follow the icon design guideline defined by AdaptiveIconDrawable.

Parameters
uri Uri: A uri referring to local content:// or file:// image data.

createWithBitmap

open static fun createWithBitmap(bits: Bitmap!): IconCompat!

Create an Icon pointing to a bitmap in memory.

Parameters
bits Bitmap!: A valid android.graphics.Bitmap object

createWithContentUri

open static fun createWithContentUri(uri: String!): IconCompat!

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

Parameters
uri String!: A uri referring to local content:// or file:// image data.

createWithContentUri

open static fun createWithContentUri(uri: Uri!): IconCompat!

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

Parameters