IconCompat

public class IconCompat
extends Object implements VersionedParcelable

java.lang.Object
   ↳ androidx.core.graphics.drawable.IconCompat


Helper for accessing features in Icon.

Summary

Constants

int TYPE_ADAPTIVE_BITMAP

An icon that was created using createWithAdaptiveBitmap(Bitmap).

int TYPE_BITMAP

An icon that was created using createWithBitmap(Bitmap).

int TYPE_DATA

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

int TYPE_RESOURCE

An icon that was created using createWithResource(Context, int).

int TYPE_UNKNOWN

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

int TYPE_URI

An icon that was created using createWithContentUri(Uri).

int TYPE_URI_ADAPTIVE_BITMAP

An icon that was created using createWithAdaptiveBitmapContentUri(Uri).

Public methods

static IconCompat createFromBundle(Bundle bundle)

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

static IconCompat createFromIcon(Context context, Icon icon)

Creates an IconCompat from an Icon.

static IconCompat createWithAdaptiveBitmap(Bitmap bits)

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

static IconCompat createWithAdaptiveBitmapContentUri(String uri)

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

static IconCompat createWithAdaptiveBitmapContentUri(Uri uri)

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

static IconCompat createWithBitmap(Bitmap bits)

Create an Icon pointing to a bitmap in memory.

static IconCompat createWithContentUri(String uri)

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

static IconCompat createWithContentUri(Uri uri)

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

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

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

static IconCompat createWithResource(Context context, int resId)

Create an Icon pointing to a drawable resource.

int getResId()

Gets the resource id used to create this icon.

String getResPackage()

Gets the package used to create this icon.

int getType()

Gets the type of the icon provided.

Uri getUri()

Gets the uri used to create this icon.

Drawable loadDrawable(Context context)

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

void onPostParceling()

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

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.

IconCompat setTint(int tint)

Store a color to use whenever this Icon is drawn.

IconCompat setTintList(ColorStateList tintList)

Store a color to use whenever this Icon is drawn.

IconCompat setTintMode(PorterDuff.Mode mode)

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

Bundle toBundle()

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

Icon toIcon()

This method is deprecated. Use toIcon(Context) to generate the Icon object.

Icon to