Stay organized with collections
Save and categorize content based on your preferences.
class ImageTransformation : Parcelable, Transformation
Replaces the content of a child ImageView
of a presentation template
with the first image that matches a regular expression (regex).
Typically used to display credit card logos. Example:
new ImageTransformation.Builder(ccNumberId, Pattern.compile("^4815.*$"),
R.drawable.ic_credit_card_logo1, "Brand 1")
.addOption(Pattern.compile("^1623.*$"), R.drawable.ic_credit_card_logo2, "Brand 2")
.addOption(Pattern.compile("^42.*$"), R.drawable.ic_credit_card_logo3, "Brand 3")
.build();
There is no imposed limit in the number of options, but keep in mind that regexs are expensive to evaluate, so use the minimum number of regexs and add the most common first (for example, if this is a tranformation for a credit card logo and the most common credit card issuers are banks X and Y, add the regexes that resolves these 2 banks first).
Summary
Inherited constants |
From class Parcelable
Int |
CONTENTS_FILE_DESCRIPTOR
Descriptor bit used with describeContents() : indicates that the Parcelable object's flattened representation includes a file descriptor.
|
Int |
PARCELABLE_WRITE_RETURN_VALUE
Flag for use with writeToParcel : the object being written is a return value, that is the result of a function such as "Parcelable someFunction() ", "void someFunction(out Parcelable) ", or "void someFunction(inout Parcelable) ". Some implementations may want to release resources at this point.
|
|
Public methods
describeContents
fun describeContents(): Int
toString
fun toString(): String
Return |
String |
a string representation of the object. |
writeToParcel
fun writeToParcel(
parcel: Parcel,
flags: Int
): Unit
Properties
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2025-02-10 UTC.
[null,null,["Last updated 2025-02-10 UTC."],[],[],null,["# ImageTransformation\n\nAdded in [API level 27](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)\n\nImageTransformation\n===================\n\n*** ** * ** ***\n\nKotlin \\|[Java](/reference/android/service/autofill/ImageTransformation \"View this page in Java\") \n\n```\nclass ImageTransformation : Parcelable, Transformation\n```\n\n|---|---------------------------------------------------|\n| [kotlin.Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html) ||\n| ↳ | [android.service.autofill.ImageTransformation](#) |\n\nReplaces the content of a child [ImageView](../../widget/ImageView.html#) of a [presentation template](../../widget/RemoteViews.html#) with the first image that matches a regular expression (regex).\n\nTypically used to display credit card logos. Example: \n\n```kotlin\nnew ImageTransformation.Builder(ccNumberId, Pattern.compile(\"^4815.*$\"),\n R.drawable.ic_credit_card_logo1, \"Brand 1\")\n .addOption(Pattern.compile(\"^1623.*$\"), R.drawable.ic_credit_card_logo2, \"Brand 2\")\n .addOption(Pattern.compile(\"^42.*$\"), R.drawable.ic_credit_card_logo3, \"Brand 3\")\n .build();\n \n```\n\nThere is no imposed limit in the number of options, but keep in mind that regexs are expensive to evaluate, so use the minimum number of regexs and add the most common first (for example, if this is a tranformation for a credit card logo and the most common credit card issuers are banks X and Y, add the regexes that resolves these 2 banks first).\n\nSummary\n-------\n\n| Nested classes ||\n|---|---------------------------------------------------------------------------------------------------------------------------------|\n| | [Builder](/reference/kotlin/android/service/autofill/ImageTransformation.Builder) Builder for [ImageTransformation](#) objects. |\n\n| Inherited constants ||\n|---|---|\n| From class [Parcelable](../../os/Parcelable.html#) |----------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html) | [CONTENTS_FILE_DESCRIPTOR](../../os/Parcelable.html#CONTENTS_FILE_DESCRIPTOR:kotlin.Int) Descriptor bit used with [describeContents()](../../os/Parcelable.html#describeContents()): indicates that the Parcelable object's flattened representation includes a file descriptor. \u003cbr /\u003e | | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html) | [PARCELABLE_WRITE_RETURN_VALUE](../../os/Parcelable.html#PARCELABLE_WRITE_RETURN_VALUE:kotlin.Int) Flag for use with [writeToParcel](../../os/Parcelable.html#writeToParcel(android.os.Parcel,%20kotlin.Int)): the object being written is a return value, that is the result of a function such as \"`Parcelable someFunction()`\", \"`void someFunction(out Parcelable)`\", or \"`void someFunction(inout Parcelable)`\". Some implementations may want to release resources at this point. \u003cbr /\u003e | ||\n\n| Public methods ||\n|----------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html) | [describeContents](#describeContents())`()` \u003cbr /\u003e |\n| [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html) | [toString](#toString())`()` \u003cbr /\u003e |\n| [Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html) | [writeToParcel](#writeToParcel(android.os.Parcel,%20kotlin.Int))`(`parcel:` `[Parcel](../../os/Parcel.html#)`, `flags:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`)` \u003cbr /\u003e |\n\n| Properties ||\n|---------------------------------------------------------------------------------------------|----------------------------------------------------------|\n| static [Parcelable.Creator](../../os/Parcelable.Creator.html#)\\\u003c[ImageTransformation](#)!\\\u003e | [CREATOR](#CREATOR:android.os.Parcelable.Creator) \u003cbr /\u003e |\n\nPublic methods\n--------------\n\n### describeContents\n\nAdded in [API level 27](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nfun describeContents(): Int\n```\n\n| Return ||\n|----------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html) | a bitmask indicating the set of special object types marshaled by this Parcelable object instance. Value is either `0` or [android.os.Parcelable#CONTENTS_FILE_DESCRIPTOR](../../os/Parcelable.html#CONTENTS_FILE_DESCRIPTOR:kotlin.Int) |\n\n### toString\n\nAdded in [API level 27](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nfun toString(): String\n```\n\n| Return ||\n|----------------------------------------------------------------------------------|----------------------------------------|\n| [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html) | a string representation of the object. |\n\n### writeToParcel\n\nAdded in [API level 27](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nfun writeToParcel(\n parcel: Parcel, \n flags: Int\n): Unit\n```\n\n| Parameters ||\n|---------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `dest` | The Parcel in which the object should be written. This value cannot be `null`. |\n| `flags` | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html): Additional flags about how the object should be written. May be 0 or [PARCELABLE_WRITE_RETURN_VALUE](../../os/Parcelable.html#PARCELABLE_WRITE_RETURN_VALUE:kotlin.Int). Value is either `0` or a combination of [android.os.Parcelable#PARCELABLE_WRITE_RETURN_VALUE](../../os/Parcelable.html#PARCELABLE_WRITE_RETURN_VALUE:kotlin.Int), and android.os.Parcelable.PARCELABLE_ELIDE_DUPLICATES |\n\nProperties\n----------\n\n### CREATOR\n\nAdded in [API level 27](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nstatic val CREATOR: Parcelable.Creator\u003cImageTransformation!\u003e\n```"]]