# 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)
class WeightedElementsComplicationData.Builder
```

<br />

*** ** * ** ***

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

You must at a minimum set the `https://developer.android.com/reference/kotlin/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/kotlin/androidx/wear/watchface/complications/data/WeightedElementsComplicationData.Builder#monochromaticImage()`, `https://developer.android.com/reference/kotlin/androidx/wear/watchface/complications/data/WeightedElementsComplicationData.Builder#smallImage()`, `https://developer.android.com/reference/kotlin/androidx/wear/watchface/complications/data/WeightedElementsComplicationData.Builder#text()` or `https://developer.android.com/reference/kotlin/androidx/wear/watchface/complications/data/WeightedElementsComplicationData.Builder#title()`.

## Summary

| ### Public constructors |
|---|
| `https://developer.android.com/reference/kotlin/androidx/wear/watchface/complications/data/WeightedElementsComplicationData.Builder#Builder(kotlin.collections.List,androidx.wear.watchface.complications.data.ComplicationText)( elements: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html<https://developer.android.com/reference/kotlin/androidx/wear/watchface/complications/data/WeightedElementsComplicationData.Element>, contentDescription: https://developer.android.com/reference/kotlin/androidx/wear/watchface/complications/data/ComplicationText )` |

| ### Public functions |
|---|---|
| `open https://developer.android.com/reference/kotlin/androidx/wear/watchface/complications/data/WeightedElementsComplicationData` | `https://developer.android.com/reference/kotlin/androidx/wear/watchface/complications/data/WeightedElementsComplicationData.Builder#build()()` Builds the `https://developer.android.com/reference/kotlin/androidx/wear/watchface/complications/data/GoalProgressComplicationData`. |
| `https://developer.android.com/reference/kotlin/androidx/wear/watchface/complications/data/WeightedElementsComplicationData.Builder` | `https://developer.android.com/reference/kotlin/androidx/wear/watchface/complications/data/WeightedElementsComplicationData.Builder#setElementBackgroundColor(kotlin.Int)(elementBackgroundColor: @https://developer.android.com/reference/kotlin/androidx/annotation/ColorInt https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` Sets the background color to use between the `https://developer.android.com/reference/kotlin/androidx/wear/watchface/complications/data/WeightedElementsComplicationData.Builder#elements()` if they are drawn segmented. |
| `https://developer.android.com/reference/kotlin/androidx/wear/watchface/complications/data/WeightedElementsComplicationData.Builder` | `https://developer.android.com/reference/kotlin/androidx/wear/watchface/complications/data/WeightedElementsComplicationData.Builder#setMonochromaticImage(androidx.wear.watchface.complications.data.MonochromaticImage)(monochromaticImage: https://developer.android.com/reference/kotlin/androidx/wear/watchface/complications/data/MonochromaticImage?)` Sets optional icon associated with the complication data. |
| `https://developer.android.com/reference/kotlin/androidx/wear/watchface/complications/data/WeightedElementsComplicationData.Builder` | `https://developer.android.com/reference/kotlin/androidx/wear/watchface/complications/data/WeightedElementsComplicationData.Builder#setSmallImage(androidx.wear.watchface.complications.data.SmallImage)(smallImage: https://developer.android.com/reference/kotlin/androidx/wear/watchface/complications/data/SmallImage?)` Sets optional image associated with the complication data. |
| `https://developer.android.com/reference/kotlin/androidx/wear/watchface/complications/data/WeightedElementsComplicationData.Builder` | `https://developer.android.com/reference/kotlin/androidx/wear/watchface/complications/data/WeightedElementsComplicationData.Builder#setTapAction(android.app.PendingIntent)(tapAction: https://developer.android.com/reference/android/app/PendingIntent.html?)` Sets optional pending intent to be invoked when the complication is tapped. |
| `https://developer.android.com/reference/kotlin/androidx/wear/watchface/complications/data/WeightedElementsComplicationData.Builder` | `https://developer.android.com/reference/kotlin/androidx/wear/watchface/complications/data/WeightedElementsComplicationData.Builder#setText(androidx.wear.watchface.complications.data.ComplicationText)(text: https://developer.android.com/reference/kotlin/androidx/wear/watchface/complications/data/ComplicationText?)` Sets optional text associated with the complication data. |
| `https://developer.android.com/reference/kotlin/androidx/wear/watchface/complications/data/WeightedElementsComplicationData.Builder` | `https://developer.android.com/reference/kotlin/androidx/wear/watchface/complications/data/WeightedElementsComplicationData.Builder#setTitle(androidx.wear.watchface.complications.data.ComplicationText)(title: https://developer.android.com/reference/kotlin/androidx/wear/watchface/complications/data/ComplicationText?)` Sets optional title associated with the complication data. |
| `https://developer.android.com/reference/kotlin/androidx/wear/watchface/complications/data/WeightedElementsComplicationData.Builder` | `https://developer.android.com/reference/kotlin/androidx/wear/watchface/complications/data/WeightedElementsComplicationData.Builder#setValidTimeRange(androidx.wear.watchface.complications.data.TimeRange)(validTimeRange: https://developer.android.com/reference/kotlin/androidx/wear/watchface/complications/data/TimeRange?)` 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)

```
Builder(
    elements: List<WeightedElementsComplicationData.Element>,
    contentDescription: ComplicationText
)
```

| Parameters |
|---|---|
| `elements: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html<https://developer.android.com/reference/kotlin/androidx/wear/watchface/complications/data/WeightedElementsComplicationData.Element>` | The breakdown of the subject into various `https://developer.android.com/reference/kotlin/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/kotlin/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/kotlin/androidx/wear/watchface/complications/data/WeightedElementsComplicationData#getMaxElements()`. |
| `contentDescription: https://developer.android.com/reference/kotlin/androidx/wear/watchface/complications/data/ComplicationText` | 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 functions

### build

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

```
open fun build(): WeightedElementsComplicationData
```

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

### setElementBackgroundColor

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

```
fun setElementBackgroundColor(elementBackgroundColor: @ColorInt Int): WeightedElementsComplicationData.Builder
```

Sets the background color to use between the `https://developer.android.com/reference/kotlin/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)

```
fun setMonochromaticImage(monochromaticImage: MonochromaticImage?): WeightedElementsComplicationData.Builder
```

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)

```
fun setSmallImage(smallImage: SmallImage?): WeightedElementsComplicationData.Builder
```

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)

```
fun setTapAction(tapAction: PendingIntent?): WeightedElementsComplicationData.Builder
```

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)

```
fun setText(text: ComplicationText?): WeightedElementsComplicationData.Builder
```

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)

```
fun setTitle(title: ComplicationText?): WeightedElementsComplicationData.Builder
```

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)

```
fun setValidTimeRange(validTimeRange: TimeRange?): WeightedElementsComplicationData.Builder
```

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