# 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)

*** ** * ** ***


```
public final class Target.Builder
```

<br />

*** ** * ** ***

Builder class for generating custom `https://developer.android.com/reference/androidx/palette/graphics/Target` instances.

## Summary

| ### Public constructors |
|---|
| `https://developer.android.com/reference/androidx/palette/graphics/Target.Builder#Builder()()` Create a new `https://developer.android.com/reference/androidx/palette/graphics/Target` builder from scratch. |
| `https://developer.android.com/reference/androidx/palette/graphics/Target.Builder#Builder(androidx.palette.graphics.Target)(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/palette/graphics/Target target)` Create a new builder based on an existing `https://developer.android.com/reference/androidx/palette/graphics/Target`. |

| ### Public methods |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/palette/graphics/Target` | `https://developer.android.com/reference/androidx/palette/graphics/Target.Builder#build()()` Builds and returns the resulting `https://developer.android.com/reference/androidx/palette/graphics/Target`. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/palette/graphics/Target.Builder` | `https://developer.android.com/reference/androidx/palette/graphics/Target.Builder#setExclusive(boolean)(boolean exclusive)` Set whether any color selected for this target is exclusive to this target only. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/palette/graphics/Target.Builder` | `https://developer.android.com/reference/androidx/palette/graphics/Target.Builder#setLightnessWeight(float)(@https://developer.android.com/reference/androidx/annotation/FloatRange(from = 0) float weight)` Set the weight of importance that this target will place on lightness values. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/palette/graphics/Target.Builder` | `https://developer.android.com/reference/androidx/palette/graphics/Target.Builder#setMaximumLightness(float)(@https://developer.android.com/reference/androidx/annotation/FloatRange(from = 0, to = 1) float value)` Set the maximum lightness value for this target. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/palette/graphics/Target.Builder` | `https://developer.android.com/reference/androidx/palette/graphics/Target.Builder#setMaximumSaturation(float)(@https://developer.android.com/reference/androidx/annotation/FloatRange(from = 0, to = 1) float value)` Set the maximum saturation value for this target. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/palette/graphics/Target.Builder` | `https://developer.android.com/reference/androidx/palette/graphics/Target.Builder#setMinimumLightness(float)(@https://developer.android.com/reference/androidx/annotation/FloatRange(from = 0, to = 1) float value)` Set the minimum lightness value for this target. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/palette/graphics/Target.Builder` | `https://developer.android.com/reference/androidx/palette/graphics/Target.Builder#setMinimumSaturation(float)(@https://developer.android.com/reference/androidx/annotation/FloatRange(from = 0, to = 1) float value)` Set the minimum saturation value for this target. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/palette/graphics/Target.Builder` | `https://developer.android.com/reference/androidx/palette/graphics/Target.Builder#setPopulationWeight(float)(@https://developer.android.com/reference/androidx/annotation/FloatRange(from = 0) float weight)` Set the weight of importance that this target will place on a color's population within the image. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/palette/graphics/Target.Builder` | `https://developer.android.com/reference/androidx/palette/graphics/Target.Builder#setSaturationWeight(float)(@https://developer.android.com/reference/androidx/annotation/FloatRange(from = 0) float weight)` Set the weight of importance that this target will place on saturation values. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/palette/graphics/Target.Builder` | `https://developer.android.com/reference/androidx/palette/graphics/Target.Builder#setTargetLightness(float)(@https://developer.android.com/reference/androidx/annotation/FloatRange(from = 0, to = 1) float value)` Set the target/ideal lightness value for this target. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/palette/graphics/Target.Builder` | `https://developer.android.com/reference/androidx/palette/graphics/Target.Builder#setTargetSaturation(float)(@https://developer.android.com/reference/androidx/annotation/FloatRange(from = 0, to = 1) float value)` 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)

```
public Builder()
```

Create a new `https://developer.android.com/reference/androidx/palette/graphics/Target` builder from scratch.

### Builder

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

```
public Builder(@NonNull Target target)
```

Create a new builder based on an existing `https://developer.android.com/reference/androidx/palette/graphics/Target`.

## Public methods

### build

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

```
public @NonNull Target build()
```

Builds and returns the resulting `https://developer.android.com/reference/androidx/palette/graphics/Target`.

### setExclusive

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

```
public @NonNull Target.Builder setExclusive(boolean exclusive)
```

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

| Parameters |
|---|---|
| `boolean exclusive` | 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)

```
public @NonNull Target.Builder setLightnessWeight(@FloatRange(from = 0) float weight)
```

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 |
|---|---|
| `https://developer.android.com/reference/androidx/palette/graphics/Target.Builder#setTargetLightness(float)` |   |

### setMaximumLightness

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

```
public @NonNull Target.Builder setMaximumLightness(@FloatRange(from = 0, to = 1) float value)
```

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)

```
public @NonNull Target.Builder setMaximumSaturation(@FloatRange(from = 0, to = 1) float value)
```

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)

```
public @NonNull Target.Builder setMinimumLightness(@FloatRange(from = 0, to = 1) float value)
```

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)

```
public @NonNull Target.Builder setMinimumSaturation(@FloatRange(from = 0, to = 1) float value)
```

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)

```
public @NonNull Target.Builder setPopulationWeight(@FloatRange(from = 0) float weight)
```

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)

```
public @NonNull Target.Builder setSaturationWeight(@FloatRange(from = 0) float weight)
```

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 |
|---|---|
| `https://developer.android.com/reference/androidx/palette/graphics/Target.Builder#setTargetSaturation(float)` |   |

### setTargetLightness

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

```
public @NonNull Target.Builder setTargetLightness(@FloatRange(from = 0, to = 1) float value)
```

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)

```
public @NonNull Target.Builder setTargetSaturation(@FloatRange(from = 0, to = 1) float value)
```

Set the target/ideal saturation value for this target.