# ImageTransformation.Builder

Added in[API level 27](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)

# Builder

*** ** * ** ***

Kotlin\|[Java](https://developer.android.com/reference/android/service/autofill/ImageTransformation.Builder "View this page in Java")  

```
class Builder
```

|---|--------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [kotlin.Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html)                                                                               ||
| ↳ | [android.service.autofill.ImageTransformation.Builder](https://developer.android.com/reference/kotlin/android/service/autofill/ImageTransformation.Builder#) |

Builder for[ImageTransformation](https://developer.android.com/reference/kotlin/android/service/autofill/ImageTransformation)objects.

## Summary

|                                                                                                                                                                                                                                                                                                                                                     Public constructors                                                                                                                                                                                                                                                                                                                                                      ||
|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---|
| [Builder](https://developer.android.com/reference/kotlin/android/service/autofill/ImageTransformation.Builder#Builder(android.view.autofill.AutofillId,%20java.util.regex.Pattern,%20kotlin.Int))`(`id:` `[AutofillId](https://developer.android.com/reference/kotlin/android/view/autofill/AutofillId.html#)`, `regex:` `[Pattern](https://developer.android.com/reference/kotlin/java/util/regex/Pattern.html#)`, `resId:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`)` Creates a new builder for a autofill id and add a first option.                                                                                                                                               |
| [Builder](https://developer.android.com/reference/kotlin/android/service/autofill/ImageTransformation.Builder#Builder(android.view.autofill.AutofillId,%20java.util.regex.Pattern,%20kotlin.Int,%20kotlin.CharSequence))`(`id:` `[AutofillId](https://developer.android.com/reference/kotlin/android/view/autofill/AutofillId.html#)`, `regex:` `[Pattern](https://developer.android.com/reference/kotlin/java/util/regex/Pattern.html#)`, `resId:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`, `contentDescription:` `[CharSequence](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-char-sequence/index.html)`)` Creates a new builder for a autofill id and add a first option. |

|                                                                                                                                                                                                                                                                                                                                                                             Public methods                                                                                                                                                                                                                                                                                                                                                                             ||
|------------------------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| open[ImageTransformation.Builder](https://developer.android.com/reference/kotlin/android/service/autofill/ImageTransformation.Builder#)! | [addOption](https://developer.android.com/reference/kotlin/android/service/autofill/ImageTransformation.Builder#addOption(java.util.regex.Pattern,%20kotlin.Int))`(`regex:` `[Pattern](https://developer.android.com/reference/kotlin/java/util/regex/Pattern.html#)`, `resId:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`)` Adds an option to replace the child view with a different image when the regex matches.                                                                                                                                                                       |
| open[ImageTransformation.Builder](https://developer.android.com/reference/kotlin/android/service/autofill/ImageTransformation.Builder#)! | [addOption](https://developer.android.com/reference/kotlin/android/service/autofill/ImageTransformation.Builder#addOption(java.util.regex.Pattern,%20kotlin.Int,%20kotlin.CharSequence))`(`regex:` `[Pattern](https://developer.android.com/reference/kotlin/java/util/regex/Pattern.html#)`, `resId:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`, `contentDescription:` `[CharSequence](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-char-sequence/index.html)`)` Adds an option to replace the child view with a different image and content description when the regex matches. |
| open[ImageTransformation](https://developer.android.com/reference/kotlin/android/service/autofill/ImageTransformation)!                  | [build](https://developer.android.com/reference/kotlin/android/service/autofill/ImageTransformation.Builder#build())`()` Creates a new[ImageTransformation](https://developer.android.com/reference/kotlin/android/service/autofill/ImageTransformation)instance.                                                                                                                                                                                                                                                                                                                                                            |

## Public constructors

### Builder

Added in[API level 27](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
Builder(
    id: AutofillId, 
    regex: Pattern, 
    resId: Int)
```

**Deprecated:** *use[Builder(android.view.autofill.AutofillId,java.util.regex.Pattern,int,java.lang.CharSequence)](https://developer.android.com/reference/kotlin/android/service/autofill/ImageTransformation.Builder#Builder(android.view.autofill.AutofillId,%20java.util.regex.Pattern,%20kotlin.Int,%20kotlin.CharSequence))instead.*

Creates a new builder for a autofill id and add a first option.

|                                                                                                                                                                                   Parameters                                                                                                                                                                                    ||
|---------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `id`    | [AutofillId](https://developer.android.com/reference/kotlin/android/view/autofill/AutofillId.html#):id of the screen field that will be used to evaluate whether the image should be used. This value cannot be`null`.                                                                                                                                                 |
| `regex` | [Pattern](https://developer.android.com/reference/kotlin/java/util/regex/Pattern.html#):regular expression defining what should be matched to use this image. This value cannot be`null`.                                                                                                                                                                              |
| `resId` | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html):resource id of the image (in the autofill service's package). The[presentation](https://developer.android.com/reference/kotlin/android/widget/RemoteViews.html#)must contain a[ImageView](https://developer.android.com/reference/kotlin/android/widget/ImageView.html#)child with that id. |

### Builder

Added in[API level 28](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
Builder(
    id: AutofillId, 
    regex: Pattern, 
    resId: Int, 
    contentDescription: CharSequence)
```

Creates a new builder for a autofill id and add a first option.

|                                                                                                                                                                                          Parameters                                                                                                                                                                                          ||
|----------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `id`                 | [AutofillId](https://developer.android.com/reference/kotlin/android/view/autofill/AutofillId.html#):id of the screen field that will be used to evaluate whether the image should be used. This value cannot be`null`.                                                                                                                                                 |
| `regex`              | [Pattern](https://developer.android.com/reference/kotlin/java/util/regex/Pattern.html#):regular expression defining what should be matched to use this image. This value cannot be`null`.                                                                                                                                                                              |
| `resId`              | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html):resource id of the image (in the autofill service's package). The[presentation](https://developer.android.com/reference/kotlin/android/widget/RemoteViews.html#)must contain a[ImageView](https://developer.android.com/reference/kotlin/android/widget/ImageView.html#)child with that id. |
| `contentDescription` | [CharSequence](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-char-sequence/index.html):content description to be applied in the child view. This value cannot be`null`.                                                                                                                                                                                         |

## Public methods

### addOption

Added in[API level 27](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  
Deprecated in[API level 28](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
open fun addOption(
    regex: Pattern, 
    resId: Int
): ImageTransformation.Builder!
```

**Deprecated:** *use[addOption(java.util.regex.Pattern,int,java.lang.CharSequence)](https://developer.android.com/reference/kotlin/android/service/autofill/ImageTransformation.Builder#addOption(java.util.regex.Pattern,%20kotlin.Int,%20kotlin.CharSequence))instead.*

Adds an option to replace the child view with a different image when the regex matches.

|                                                                                                                                                                                   Parameters                                                                                                                                                                                    ||
|---------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `regex` | [Pattern](https://developer.android.com/reference/kotlin/java/util/regex/Pattern.html#):regular expression defining what should be matched to use this image. This value cannot be`null`.                                                                                                                                                                              |
| `resId` | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html):resource id of the image (in the autofill service's package). The[presentation](https://developer.android.com/reference/kotlin/android/widget/RemoteViews.html#)must contain a[ImageView](https://developer.android.com/reference/kotlin/android/widget/ImageView.html#)child with that id. |

|                                                                      Return                                                                      ||
|--------------------------------------------------------------------------------------------------------------------------------------|------------|
| [ImageTransformation.Builder](https://developer.android.com/reference/kotlin/android/service/autofill/ImageTransformation.Builder#)! | this build |

### addOption

Added in[API level 28](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
open fun addOption(
    regex: Pattern, 
    resId: Int, 
    contentDescription: CharSequence
): ImageTransformation.Builder!
```

Adds an option to replace the child view with a different image and content description when the regex matches.

|                                                                                                                                                                                          Parameters                                                                                                                                                                                          ||
|----------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `regex`              | [Pattern](https://developer.android.com/reference/kotlin/java/util/regex/Pattern.html#):regular expression defining what should be matched to use this image. This value cannot be`null`.                                                                                                                                                                              |
| `resId`              | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html):resource id of the image (in the autofill service's package). The[presentation](https://developer.android.com/reference/kotlin/android/widget/RemoteViews.html#)must contain a[ImageView](https://developer.android.com/reference/kotlin/android/widget/ImageView.html#)child with that id. |
| `contentDescription` | [CharSequence](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-char-sequence/index.html):content description to be applied in the child view. This value cannot be`null`.                                                                                                                                                                                         |

|                                                                      Return                                                                      ||
|--------------------------------------------------------------------------------------------------------------------------------------|------------|
| [ImageTransformation.Builder](https://developer.android.com/reference/kotlin/android/service/autofill/ImageTransformation.Builder#)! | this build |

### build

Added in[API level 27](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
open fun build(): ImageTransformation!
```

Creates a new[ImageTransformation](https://developer.android.com/reference/kotlin/android/service/autofill/ImageTransformation)instance.