# Target.Builder

# Target.Builder

Artifact:[androidx.palette:palette](https://developer.android.com/jetpack/androidx/releases/palette)  
[View Source](https://cs.android.com/search?q=file:androidx/palette/graphics/Target.java+class:androidx.palette.graphics.Target.Builder)  
Added in[1.0.0](https://developer.android.com/jetpack/androidx/releases/palette#1.0.0)

*** ** * ** ***

Kotlin\|[Java](https://developer.android.com/reference/androidx/palette/graphics/Target.Builder "View this page in Java")

<br />

```
class Target.Builder
```

<br />

*** ** * ** ***

Builder class for generating custom[Target](https://developer.android.com/reference/kotlin/androidx/palette/graphics/Target)instances.

## Summary

|                                                                                                                                                                                 ### Public constructors                                                                                                                                                                                 |
|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [Builder](https://developer.android.com/reference/kotlin/androidx/palette/graphics/Target.Builder#Builder())`()` Create a new[Target](https://developer.android.com/reference/kotlin/androidx/palette/graphics/Target)builder from scratch.                                                                                                                                             |
| [Builder](https://developer.android.com/reference/kotlin/androidx/palette/graphics/Target.Builder#Builder(androidx.palette.graphics.Target))`(target: `[Target](https://developer.android.com/reference/kotlin/androidx/palette/graphics/Target)`)` Create a new builder based on an existing[Target](https://developer.android.com/reference/kotlin/androidx/palette/graphics/Target). |

|                                           ### Public functions                                            |
|-----------------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [Target](https://developer.android.com/reference/kotlin/androidx/palette/graphics/Target)                 | [build](https://developer.android.com/reference/kotlin/androidx/palette/graphics/Target.Builder#build())`()` Builds and returns the resulting[Target](https://developer.android.com/reference/kotlin/androidx/palette/graphics/Target).                                                                                                                                                                                                            |
| [Target.Builder](https://developer.android.com/reference/kotlin/androidx/palette/graphics/Target.Builder) | [setExclusive](https://developer.android.com/reference/kotlin/androidx/palette/graphics/Target.Builder#setExclusive(boolean))`(exclusive: `[Boolean](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html)`)` Set whether any color selected for this target is exclusive to this target only.                                                                                                                                 |
| [Target.Builder](https://developer.android.com/reference/kotlin/androidx/palette/graphics/Target.Builder) | [setLightnessWeight](https://developer.android.com/reference/kotlin/androidx/palette/graphics/Target.Builder#setLightnessWeight(float))`(weight: @`[FloatRange](https://developer.android.com/reference/kotlin/androidx/annotation/FloatRange)`(from = 0) `[Float](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html)`)` Set the weight of importance that this target will place on lightness values.                        |
| [Target.Builder](https://developer.android.com/reference/kotlin/androidx/palette/graphics/Target.Builder) | [setMaximumLightness](https://developer.android.com/reference/kotlin/androidx/palette/graphics/Target.Builder#setMaximumLightness(float))`(value: @`[FloatRange](https://developer.android.com/reference/kotlin/androidx/annotation/FloatRange)`(from = 0, to = 1) `[Float](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html)`)` Set the maximum lightness value for this target.                                            |
| [Target.Builder](https://developer.android.com/reference/kotlin/androidx/palette/graphics/Target.Builder) | [setMaximumSaturation](https://developer.android.com/reference/kotlin/androidx/palette/graphics/Target.Builder#setMaximumSaturation(float))`(value: @`[FloatRange](https://developer.android.com/reference/kotlin/androidx/annotation/FloatRange)`(from = 0, to = 1) `[Float](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html)`)` Set the maximum saturation value for this target.                                         |
| [Target.Builder](https://developer.android.com/reference/kotlin/androidx/palette/graphics/Target.Builder) | [setMinimumLightness](https://developer.android.com/reference/kotlin/androidx/palette/graphics/Target.Builder#setMinimumLightness(float))`(value: @`[FloatRange](https://developer.android.com/reference/kotlin/androidx/annotation/FloatRange)`(from = 0, to = 1) `[Float](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html)`)` Set the minimum lightness value for this target.                                            |
| [Target.Builder](https://developer.android.com/reference/kotlin/androidx/palette/graphics/Target.Builder) | [setMinimumSaturation](https://developer.android.com/reference/kotlin/androidx/palette/graphics/Target.Builder#setMinimumSaturation(float))`(value: @`[FloatRange](https://developer.android.com/reference/kotlin/androidx/annotation/FloatRange)`(from = 0, to = 1) `[Float](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html)`)` Set the minimum saturation value for this target.                                         |
| [Target.Builder](https://developer.android.com/reference/kotlin/androidx/palette/graphics/Target.Builder) | [setPopulationWeight](https://developer.android.com/reference/kotlin/androidx/palette/graphics/Target.Builder#setPopulationWeight(float))`(weight: @`[FloatRange](https://developer.android.com/reference/kotlin/androidx/annotation/FloatRange)`(from = 0) `[Float](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html)`)` Set the weight of importance that this target will place on a color's population within the image. |
| [Target.Builder](https://developer.android.com/reference/kotlin/androidx/palette/graphics/Target.Builder) | [setSaturationWeight](https://developer.android.com/reference/kotlin/androidx/palette/graphics/Target.Builder#setSaturationWeight(float))`(weight: @`[FloatRange](https://developer.android.com/reference/kotlin/androidx/annotation/FloatRange)`(from = 0) `[Float](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html)`)` Set the weight of importance that this target will place on saturation values.                     |
| [Target.Builder](https://developer.android.com/reference/kotlin/androidx/palette/graphics/Target.Builder) | [setTargetLightness](https://developer.android.com/reference/kotlin/androidx/palette/graphics/Target.Builder#setTargetLightness(float))`(value: @`[FloatRange](https://developer.android.com/reference/kotlin/androidx/annotation/FloatRange)`(from = 0, to = 1) `[Float](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html)`)` Set the target/ideal lightness value for this target.                                         |
| [Target.Builder](https://developer.android.com/reference/kotlin/androidx/palette/graphics/Target.Builder) | [setTargetSaturation](https://developer.android.com/reference/kotlin/androidx/palette/graphics/Target.Builder#setTargetSaturation(float))`(value: @`[FloatRange](https://developer.android.com/reference/kotlin/androidx/annotation/FloatRange)`(from = 0, to = 1) `[Float](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html)`)` Set the target/ideal saturation value for this target.                                      |

## Public constructors

### Builder

Added in[1.0.0](https://developer.android.com/jetpack/androidx/releases/palette#1.0.0)  

```
Builder()
```

Create a new[Target](https://developer.android.com/reference/kotlin/androidx/palette/graphics/Target)builder from scratch.  

### Builder

Added in[1.0.0](https://developer.android.com/jetpack/androidx/releases/palette#1.0.0)  

```
Builder(target: Target)
```

Create a new builder based on an existing[Target](https://developer.android.com/reference/kotlin/androidx/palette/graphics/Target).  

## Public functions

### build

Added in[1.0.0](https://developer.android.com/jetpack/androidx/releases/palette#1.0.0)  

```
fun build(): Target
```

Builds and returns the resulting[Target](https://developer.android.com/reference/kotlin/androidx/palette/graphics/Target).  

### setExclusive

Added in[1.0.0](https://developer.android.com/jetpack/androidx/releases/palette#1.0.0)  

```
fun setExclusive(exclusive: Boolean): Target.Builder
```

Set whether any color selected for this target is exclusive to this target only. Defaults to true.  

|                                            Parameters                                            |
|--------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------|
| `exclusive: `[Boolean](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html) | true if any the color is exclusive to this target, or false is the color can be selected for other targets. |

### setLightnessWeight

Added in[1.0.0](https://developer.android.com/jetpack/androidx/releases/palette#1.0.0)  

```
fun setLightnessWeight(weight: @FloatRange(from = 0) Float): Target.Builder
```

Set the weight of importance that this target will place on lightness values.

The larger the weight, relative to the other weights, the more important that a color being close to the target value has on selection.

A weight of 0 means that it has no weight, and thus has no bearing on the selection.  

|                                                                See also                                                                 |
|-----------------------------------------------------------------------------------------------------------------------------------------|---|
| [setTargetLightness](https://developer.android.com/reference/kotlin/androidx/palette/graphics/Target.Builder#setTargetLightness(float)) |   |

### setMaximumLightness

Added in[1.0.0](https://developer.android.com/jetpack/androidx/releases/palette#1.0.0)  

```
fun setMaximumLightness(value: @FloatRange(from = 0, to = 1) Float): Target.Builder
```

Set the maximum lightness value for this target.  

### setMaximumSaturation

Added in[1.0.0](https://developer.android.com/jetpack/androidx/releases/palette#1.0.0)  

```
fun setMaximumSaturation(value: @FloatRange(from = 0, to = 1) Float): Target.Builder
```

Set the maximum saturation value for this target.  

### setMinimumLightness

Added in[1.0.0](https://developer.android.com/jetpack/androidx/releases/palette#1.0.0)  

```
fun setMinimumLightness(value: @FloatRange(from = 0, to = 1) Float): Target.Builder
```

Set the minimum lightness value for this target.  

### setMinimumSaturation

Added in[1.0.0](https://developer.android.com/jetpack/androidx/releases/palette#1.0.0)  

```
fun setMinimumSaturation(value: @FloatRange(from = 0, to = 1) Float): Target.Builder
```

Set the minimum saturation value for this target.  

### setPopulationWeight

Added in[1.0.0](https://developer.android.com/jetpack/androidx/releases/palette#1.0.0)  

```
fun setPopulationWeight(weight: @FloatRange(from = 0) Float): Target.Builder
```

Set the weight of importance that this target will place on a color's population within the image.

The larger the weight, relative to the other weights, the more important that a color's population being close to the most populous has on selection.

A weight of 0 means that it has no weight, and thus has no bearing on the selection.  

### setSaturationWeight

Added in[1.0.0](https://developer.android.com/jetpack/androidx/releases/palette#1.0.0)  

```
fun setSaturationWeight(weight: @FloatRange(from = 0) Float): Target.Builder
```

Set the weight of importance that this target will place on saturation values.

The larger the weight, relative to the other weights, the more important that a color being close to the target value has on selection.

A weight of 0 means that it has no weight, and thus has no bearing on the selection.  

|                                                                 See also                                                                  |
|-------------------------------------------------------------------------------------------------------------------------------------------|---|
| [setTargetSaturation](https://developer.android.com/reference/kotlin/androidx/palette/graphics/Target.Builder#setTargetSaturation(float)) |   |

### setTargetLightness

Added in[1.0.0](https://developer.android.com/jetpack/androidx/releases/palette#1.0.0)  

```
fun setTargetLightness(value: @FloatRange(from = 0, to = 1) Float): Target.Builder
```

Set the target/ideal lightness value for this target.  

### setTargetSaturation

Added in[1.0.0](https://developer.android.com/jetpack/androidx/releases/palette#1.0.0)  

```
fun setTargetSaturation(value: @FloatRange(from = 0, to = 1) Float): Target.Builder
```

Set the target/ideal saturation value for this target.