# WeightedElementsComplicationData.Builder

Artifact: [androidx.wear.watchface:watchface-complications-data](https://developer.android.com/jetpack/androidx/releases/wear-watchface) [View Source](https://cs.android.com/search?q=file:androidx/wear/watchface/complications/data/Data.kt+class:androidx.wear.watchface.complications.data.WeightedElementsComplicationData.Builder) Added in [1.2.0](https://developer.android.com/jetpack/androidx/releases/wear-watchface#1.2.0)

*** ** * ** ***

<br />

```
@RequiresApi(value = 33)
public final class WeightedElementsComplicationData.Builder
```

<br />

*** ** * ** ***

Builder for `https://developer.android.com/reference/androidx/wear/watchface/complications/data/WeightedElementsComplicationData`.

You must at a minimum set the `https://developer.android.com/reference/androidx/wear/watchface/complications/data/WeightedElementsComplicationData.Builder#(kotlin.collections.List,androidx.wear.watchface.complications.data.ComplicationText)` field and at least one of `https://developer.android.com/reference/androidx/wear/watchface/complications/data/WeightedElementsComplicationData.Builder#monochromaticImage()`, `https://developer.android.com/reference/androidx/wear/watchface/complications/data/WeightedElementsComplicationData.Builder#smallImage()`, `https://developer.android.com/reference/androidx/wear/watchface/complications/data/WeightedElementsComplicationData.Builder#text()` or `https://developer.android.com/reference/androidx/wear/watchface/complications/data/WeightedElementsComplicationData.Builder#title()`.

## Summary

| ### Public constructors |
|---|
| `https://developer.android.com/reference/androidx/wear/watchface/complications/data/WeightedElementsComplicationData.Builder#Builder(kotlin.collections.List,androidx.wear.watchface.complications.data.ComplicationText)( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/List.html<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/wear/watchface/complications/data/WeightedElementsComplicationData.Element> elements, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/wear/watchface/complications/data/ComplicationText contentDescription )` |

| ### Public methods |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/wear/watchface/complications/data/WeightedElementsComplicationData` | `https://developer.android.com/reference/androidx/wear/watchface/complications/data/WeightedElementsComplicationData.Builder#build()()` Builds the `https://developer.android.com/reference/androidx/wear/watchface/complications/data/GoalProgressComplicationData`. |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/wear/watchface/complications/data/WeightedElementsComplicationData.Builder` | `https://developer.android.com/reference/androidx/wear/watchface/complications/data/WeightedElementsComplicationData.Builder#setElementBackgroundColor(kotlin.Int)(@https://developer.android.com/reference/androidx/annotation/ColorInt int elementBackgroundColor)` Sets the background color to use between the `https://developer.android.com/reference/androidx/wear/watchface/complications/data/WeightedElementsComplicationData.Builder#elements()` if they are drawn segmented. |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/wear/watchface/complications/data/WeightedElementsComplicationData.Builder` | `https://developer.android.com/reference/androidx/wear/watchface/complications/data/WeightedElementsComplicationData.Builder#setMonochromaticImage(androidx.wear.watchface.complications.data.MonochromaticImage)(https://developer.android.com/reference/androidx/wear/watchface/complications/data/MonochromaticImage monochromaticImage)` Sets optional icon associated with the complication data. |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/wear/watchface/complications/data/WeightedElementsComplicationData.Builder` | `https://developer.android.com/reference/androidx/wear/watchface/complications/data/WeightedElementsComplicationData.Builder#setSmallImage(androidx.wear.watchface.complications.data.SmallImage)(https://developer.android.com/reference/androidx/wear/watchface/complications/data/SmallImage smallImage)` Sets optional image associated with the complication data. |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/wear/watchface/complications/data/WeightedElementsComplicationData.Builder` | `https://developer.android.com/reference/androidx/wear/watchface/complications/data/WeightedElementsComplicationData.Builder#setTapAction(android.app.PendingIntent)(https://developer.android.com/reference/android/app/PendingIntent.html tapAction)` Sets optional pending intent to be invoked when the complication is tapped. |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/wear/watchface/complications/data/WeightedElementsComplicationData.Builder` | `https://developer.android.com/reference/androidx/wear/watchface/complications/data/WeightedElementsComplicationData.Builder#setText(androidx.wear.watchface.complications.data.ComplicationText)(https://developer.android.com/reference/androidx/wear/watchface/complications/data/ComplicationText text)` Sets optional text associated with the complication data. |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/wear/watchface/complications/data/WeightedElementsComplicationData.Builder` | `https://developer.android.com/reference/androidx/wear/watchface/complications/data/WeightedElementsComplicationData.Builder#setTitle(androidx.wear.watchface.complications.data.ComplicationText)(https://developer.android.com/reference/androidx/wear/watchface/complications/data/ComplicationText title)` Sets optional title associated with the complication data. |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/wear/watchface/complications/data/WeightedElementsComplicationData.Builder` | `https://developer.android.com/reference/androidx/wear/watchface/complications/data/WeightedElementsComplicationData.Builder#setValidTimeRange(androidx.wear.watchface.complications.data.TimeRange)(https://developer.android.com/reference/androidx/wear/watchface/complications/data/TimeRange validTimeRange)` Sets optional time range during which the complication has to be shown. |

## Public constructors

### Builder

Added in [1.2.0](https://developer.android.com/jetpack/androidx/releases/wear-watchface#1.2.0)

```
public Builder(
    @NonNull List<@NonNull WeightedElementsComplicationData.Element> elements,
    @NonNull ComplicationText contentDescription
)
```

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/List.html<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/wear/watchface/complications/data/WeightedElementsComplicationData.Element> elements` | The breakdown of the subject into various `https://developer.android.com/reference/androidx/wear/watchface/complications/data/WeightedElementsComplicationData.Element`s. E.g. the proportion of calories consumed which were carbohydrates, fats etc... The `https://developer.android.com/reference/androidx/wear/watchface/complications/data/WeightedElementsComplicationData.Builder#tapAction()` must take the user to an experience where the color key becomes obvious. The maximum valid size of this list is provided by `https://developer.android.com/reference/androidx/wear/watchface/complications/data/WeightedElementsComplicationData#getMaxElements()`. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/wear/watchface/complications/data/ComplicationText contentDescription` | Defines localized text that briefly describes content of the complication. This property is used primarily for accessibility. Since some complications do not have textual representation this attribute can be used for providing such. Please do not include the word 'complication' in the description. |

## Public methods

### build

Added in [1.2.0](https://developer.android.com/jetpack/androidx/releases/wear-watchface#1.2.0)

```
public @NonNull WeightedElementsComplicationData build()
```

Builds the `https://developer.android.com/reference/androidx/wear/watchface/complications/data/GoalProgressComplicationData`.

### setElementBackgroundColor

Added in [1.2.0](https://developer.android.com/jetpack/androidx/releases/wear-watchface#1.2.0)

```
public final @NonNull WeightedElementsComplicationData.Builder setElementBackgroundColor(@ColorInt int elementBackgroundColor)
```

Sets the background color to use between the `https://developer.android.com/reference/androidx/wear/watchface/complications/data/WeightedElementsComplicationData.Builder#elements()` if they are drawn segmented. Defaults to `https://developer.android.com/reference/android/graphics/Color.html#TRANSPARENT` if not set.

### setMonochromaticImage

Added in [1.2.0](https://developer.android.com/jetpack/androidx/releases/wear-watchface#1.2.0)

```
public final @NonNull WeightedElementsComplicationData.Builder setMonochromaticImage(MonochromaticImage monochromaticImage)
```

Sets optional icon associated with the complication data.

### setSmallImage

Added in [1.2.0](https://developer.android.com/jetpack/androidx/releases/wear-watchface#1.2.0)

```
public final @NonNull WeightedElementsComplicationData.Builder setSmallImage(SmallImage smallImage)
```

Sets optional image associated with the complication data.

### setTapAction

Added in [1.2.0](https://developer.android.com/jetpack/androidx/releases/wear-watchface#1.2.0)

```
public final @NonNull WeightedElementsComplicationData.Builder setTapAction(PendingIntent tapAction)
```

Sets optional pending intent to be invoked when the complication is tapped.

### setText

Added in [1.2.0](https://developer.android.com/jetpack/androidx/releases/wear-watchface#1.2.0)

```
public final @NonNull WeightedElementsComplicationData.Builder setText(ComplicationText text)
```

Sets optional text associated with the complication data.

### setTitle

Added in [1.2.0](https://developer.android.com/jetpack/androidx/releases/wear-watchface#1.2.0)

```
public final @NonNull WeightedElementsComplicationData.Builder setTitle(ComplicationText title)
```

Sets optional title associated with the complication data.

### setValidTimeRange

Added in [1.2.0](https://developer.android.com/jetpack/androidx/releases/wear-watchface#1.2.0)

```
public final @NonNull WeightedElementsComplicationData.Builder setValidTimeRange(TimeRange validTimeRange)
```

Sets optional time range during which the complication has to be shown.