IconCompat
class IconCompat : VersionedParcelable
Helper for accessing features in android.graphics.drawable.Icon.
Summary
Constants |
|
|---|---|
const Int |
An icon that was created using |
const Int |
TYPE_BITMAP = 1An icon that was created using |
const Int |
TYPE_DATA = 3An icon that was created using |
const Int |
TYPE_RESOURCE = 2An icon that was created using |
const Int |
TYPE_UNKNOWN = -1Value returned when the type of an |
const Int |
TYPE_URI = 4An icon that was created using |
const Int |
An icon that was created using |
Public functions |
|
|---|---|
java-static IconCompat? |
createFromBundle(bundle: Bundle)Extracts an icon from a bundle that was added using |
java-static IconCompat |
createFromIcon(context: Context, icon: Icon)Creates an IconCompat from an Icon. |
java-static IconCompat |
createWithAdaptiveBitmap(bits: Bitmap)Create an Icon pointing to a bitmap in memory that follows the icon design guideline defined by |
java-static IconCompat |
Create an Icon pointing to an image file specified by URI. |
java-static IconCompat |
Create an Icon pointing to an image file specified by URI. |
java-static IconCompat |
createWithBitmap(bits: Bitmap)Create an Icon pointing to a bitmap in memory. |
java-static IconCompat |
createWithContentUri(uri: String)Create an Icon pointing to an image file specified by URI. |
java-static IconCompat |
createWithContentUri(uri: Uri)Create an Icon pointing to an image file specified by URI. |
java-static IconCompat |
createWithData(data: ByteArray<Byte>, offset: Int, length: Int)Create an Icon pointing to a compressed bitmap stored in a byte array. |
java-static IconCompat |
createWithResource(context: Context, resId: @DrawableRes Int)Create an Icon pointing to a drawable resource. |
@DrawableRes Int |
getResId()Gets the drawable resource id used to create this icon. |
String |
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. |
Unit |
Called immediately after this object has been deserialized, can be used to handle any custom fields that cannot be easily annotated. |
Unit |
onPreParceling(isStream: Boolean)Called immediately before this object is going to be serialized, can be used to handle any custom fields that cannot be easily annotated. |
IconCompat |
Store a color to use whenever this Icon is drawn. |
IconCompat |
setTintList(tintList: ColorStateList?)Store a color to use whenever this Icon is drawn. |
IconCompat |
setTintMode(mode: PorterDuff.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 |
Icon |
This function is deprecated. |
Icon |
Convert this compat object to |
String |
toString() |
Constants
TYPE_ADAPTIVE_BITMAP
const val TYPE_ADAPTIVE_BITMAP = 5: Int
An icon that was created using createWithAdaptiveBitmap.
TYPE_BITMAP
const val TYPE_BITMAP = 1: Int
An icon that was created using createWithBitmap.
TYPE_DATA
const val TYPE_DATA = 3: Int
An icon that was created using createWithData.
TYPE_RESOURCE
const val TYPE_RESOURCE = 2: Int
An icon that was created using createWithResource.
TYPE_UNKNOWN
const val TYPE_UNKNOWN = -1: Int
Value returned when the type of an Icon cannot be determined.
TYPE_URI
const val TYPE_URI = 4: Int
An icon that was created using createWithContentUri.
TYPE_URI_ADAPTIVE_BITMAP
const val TYPE_URI_ADAPTIVE_BITMAP = 6: Int
An icon that was created using createWithAdaptiveBitmapContentUri.
Public functions
createFromBundle
java-static fun createFromBundle(bundle: Bundle): IconCompat?
Extracts an icon from a bundle that was added using toBundle.
createFromIcon
java-static fun createFromIcon(context: Context, icon: Icon): IconCompat
Creates an IconCompat from an Icon.
createWithAdaptiveBitmap
java-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 |
| See also | |
|---|---|
createWithAdaptiveBitmap |
createWithAdaptiveBitmapContentUri
java-static fun createWithAdaptiveBitmapContentUri(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. |
| See also | |
|---|---|
createWithAdaptiveBitmapContentUri |
createWithAdaptiveBitmapContentUri
java-static fun createWithAdaptiveBitmapContentUri(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. |
| See also | |
|---|---|
createWithAdaptiveBitmapContentUri |
createWithBitmap
java-static fun createWithBitmap(bits: Bitmap): IconCompat
Create an Icon pointing to a bitmap in memory.
| Parameters | |
|---|---|
bits: Bitmap |
A valid |
| See also | |
|---|---|
createWithBitmap |
createWithContentUri
java-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. |
| See also | |
|---|---|
createWithContentUri |
createWithContentUri
java-static fun createWithContentUri(uri: Uri): IconCompat
Create an Icon pointing to an image file specified by URI.
| Parameters | |
|---|---|
uri: Uri |
A uri referring to local content:// or file:// image data. |
| See also | |
|---|---|
createWithContentUri |
createWithData
java-static fun createWithData(data: ByteArray<Byte>, offset: Int, length: Int): IconCompat
Create an Icon pointing to a compressed bitmap stored in a byte array.
| Parameters | |
|---|---|
data: ByteArray<Byte> |
Byte array storing compressed bitmap data of a type that |
offset: Int |
Offset into |
length: Int |
Length of the bitmap data |
| See also | |
|---|---|
createWithData |
createWithResource
java-static fun createWithResource(context: Context, resId: @DrawableRes Int): IconCompat
Create an Icon pointing to a drawable resource.
| Parameters | |
|---|---|
context: Context |
The context for the application whose resources should be used to resolve the given resource ID. |
resId: @DrawableRes Int |
ID of the drawable resource |
| See also | |
|---|---|
createWithResource |
getResId
fun getResId(): @DrawableRes Int
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
fun getResPackage(): String
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
fun getType(): Int
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
fun getUri(): Uri
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
fun loadDrawable(context: Context): Drawable?
Returns a Drawable that can be used to draw the image inside this Icon, constructing it if necessary.
| Parameters | |
|---|---|
context: Context |
|
| Returns | |
|---|---|
Drawable? |
A fresh instance of a drawable for this image, yours to keep. |
onPostParceling
fun onPostParceling(): Unit
Called immediately after this object has been deserialized, can be used to handle any custom fields that cannot be easily annotated.
onPreParceling
fun onPreParceling(isStream: Boolean): Unit
Called immediately before this object is going to be serialized, can be used to handle any custom fields that cannot be easily annotated.
setTint
fun setTint(tint: @ColorInt Int): IconCompat
Store a color to use whenever this Icon is drawn.
| Returns | |
|---|---|
IconCompat |
this same object, for use in chained construction |
setTintList
fun setTintList(tintList: ColorStateList?): IconCompat
Store a color to use whenever this Icon is drawn.
| Parameters | |
|---|---|
tintList: ColorStateList? |
as in |
| Returns | |
|---|---|
IconCompat |
this same object, for use in chained construction |
setTintMode
fun setTintMode(mode: PorterDuff.Mode?): IconCompat
Store a blending mode to use whenever this Icon is drawn.
| Parameters | |
|---|---|
mode: PorterDuff.Mode? |
a blending mode, as in |
| Returns | |
|---|---|
IconCompat |
this same object, for use in chained construction |
toBundle
fun toBundle(): Bundle
Adds this Icon to a Bundle that can be read back with the same parameters to createFromBundle.