# Chip.Builder

# Chip.Builder

Artifact:[androidx.wear.protolayout:protolayout-material](https://developer.android.com/jetpack/androidx/releases/wear-protolayout)  
[View Source](https://cs.android.com/search?q=file:androidx/wear/protolayout/material/Chip.java+class:androidx.wear.protolayout.material.Chip.Builder)  
Added in[1.0.0](https://developer.android.com/jetpack/androidx/releases/wear-protolayout#1.0.0)

*** ** * ** ***

Kotlin\|[Java](https://developer.android.com/reference/androidx/wear/protolayout/material/Chip.Builder "View this page in Java")

<br />

```
class Chip.Builder
```

<br />

*** ** * ** ***

Builder class for[Chip](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/material/Chip).

## Summary

|                                                                                                                                                                                                                                                                                                                                                                                                                       ### Public constructors                                                                                                                                                                                                                                                                                                                                                                                                                       |
|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [Builder](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/material/Chip.Builder#Builder(android.content.Context,androidx.wear.protolayout.ModifiersBuilders.Clickable,androidx.wear.protolayout.DeviceParametersBuilders.DeviceParameters))`(` ` context: `[Context](https://developer.android.com/reference/android/content/Context.html)`,` ` clickable: `[ModifiersBuilders.Clickable](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/ModifiersBuilders.Clickable)`,` ` deviceParameters: `[DeviceParametersBuilders.DeviceParameters](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/DeviceParametersBuilders.DeviceParameters) `)` Creates a builder for the[Chip](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/material/Chip)with associated action. |

|                                              ### Public functions                                              |
|----------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [Chip](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/material/Chip)                 | [build](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/material/Chip.Builder#build())`()` Constructs and returns[Chip](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/material/Chip)with the provided content and look.                                                                                                                                                                                                                         |
| [Chip.Builder](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/material/Chip.Builder) | [setChipColors](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/material/Chip.Builder#setChipColors(androidx.wear.protolayout.material.ChipColors))`(chipColors: `[ChipColors](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/material/ChipColors)`)` Sets the colors for the[Chip](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/material/Chip).                                                                     |
| [Chip.Builder](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/material/Chip.Builder) | [setContentDescription](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/material/Chip.Builder#setContentDescription(java.lang.CharSequence))`(contentDescription: `[CharSequence](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-char-sequence/index.html)`)` Sets the static content description for the[Chip](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/material/Chip).                                                            |
| [Chip.Builder](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/material/Chip.Builder) | [setContentDescription](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/material/Chip.Builder#setContentDescription(androidx.wear.protolayout.TypeBuilders.StringProp))`(contentDescription: `[TypeBuilders.StringProp](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/TypeBuilders.StringProp)`)` Sets the content description for the[Chip](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/material/Chip).           |
| [Chip.Builder](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/material/Chip.Builder) | [setCustomContent](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/material/Chip.Builder#setCustomContent(androidx.wear.protolayout.LayoutElementBuilders.LayoutElement))`(content: `[LayoutElementBuilders.LayoutElement](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/LayoutElementBuilders.LayoutElement)`)` Sets the custom content for the[Chip](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/material/Chip). |
| [Chip.Builder](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/material/Chip.Builder) | [setHorizontalAlignment](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/material/Chip.Builder#setHorizontalAlignment(int))`(horizontalAlignment: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`)` Sets the horizontal alignment in the chip.                                                                                                                                                                                               |
| [Chip.Builder](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/material/Chip.Builder) | [setIconContent](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/material/Chip.Builder#setIconContent(java.lang.String))`(imageResourceId: `[String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)`)` Sets the icon for the[Chip](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/material/Chip).                                                                                                                      |
| [Chip.Builder](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/material/Chip.Builder) | [setPrimaryLabelContent](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/material/Chip.Builder#setPrimaryLabelContent(java.lang.String))`(primaryLabel: `[String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)`)` Sets the primary label for the[Chip](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/material/Chip).                                                                                                |
| [Chip.Builder](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/material/Chip.Builder) | [setSecondaryLabelContent](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/material/Chip.Builder#setSecondaryLabelContent(java.lang.String))`(secondaryLabel: `[String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)`)` Sets the secondary label for the[Chip](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/material/Chip).                                                                                        |
| [Chip.Builder](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/material/Chip.Builder) | [setWidth](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/material/Chip.Builder#setWidth(androidx.wear.protolayout.DimensionBuilders.ContainerDimension))`(width: `[DimensionBuilders.ContainerDimension](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/DimensionBuilders.ContainerDimension)`)` Sets the width of[Chip](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/material/Chip).                              |
| [Chip.Builder](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/material/Chip.Builder) | [setWidth](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/material/Chip.Builder#setWidth(float))`(width: @`[Dimension](https://developer.android.com/reference/kotlin/androidx/annotation/Dimension)`(unit = 0) `[Float](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html)`)` Sets the width of[Chip](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/material/Chip).                                                      |

## Public constructors

### Builder

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

```
Builder(
    context: Context,
    clickable: ModifiersBuilders.Clickable,
    deviceParameters: DeviceParametersBuilders.DeviceParameters
)
```

Creates a builder for the[Chip](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/material/Chip)with associated action. It is required to add content later with setters.  

|                                                                                     Parameters                                                                                      |
|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `context: `[Context](https://developer.android.com/reference/android/content/Context.html)                                                                                          | The application's context.                                                                                                                                                                                |
| `clickable: `[ModifiersBuilders.Clickable](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/ModifiersBuilders.Clickable)                                    | Associated[Clickable](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/ModifiersBuilders.Clickable)for click events. When the Chip is clicked it will fire the associated action. |
| `deviceParameters: `[DeviceParametersBuilders.DeviceParameters](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/DeviceParametersBuilders.DeviceParameters) | The device parameters used to derive defaults for this Chip.                                                                                                                                              |

## Public functions

### build

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

```
fun build(): Chip
```

Constructs and returns[Chip](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/material/Chip)with the provided content and look.  

### setChipColors

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

```
fun setChipColors(chipColors: ChipColors): Chip.Builder
```

Sets the colors for the[Chip](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/material/Chip). If set,[getBackgroundColor](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/material/ChipColors#getBackgroundColor())will be used for the background of the button,[getContentColor](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/material/ChipColors#getContentColor())for main text,[getSecondaryContentColor](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/material/ChipColors#getSecondaryContentColor())for label text and[getIconColor](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/material/ChipColors#getIconColor())will be used as color for the icon itself. If not set,[PRIMARY_COLORS](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/material/ChipDefaults#PRIMARY_COLORS())will be used.  

### setContentDescription

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

```
fun setContentDescription(contentDescription: CharSequence): Chip.Builder
```

Sets the static content description for the[Chip](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/material/Chip). It is highly recommended to provide this for chip containing icon.  

### setContentDescription

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

```
fun setContentDescription(contentDescription: TypeBuilders.StringProp): Chip.Builder
```

Sets the content description for the[Chip](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/material/Chip). It is highly recommended to provide this for chip containing icon.

While this field is statically accessible from 1.0, it's only bindable since version 1.2 and renderers supporting version 1.2 will use the dynamic value (if set).  

### setCustomContent

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

```
fun setCustomContent(content: LayoutElementBuilders.LayoutElement): Chip.Builder
```

Sets the custom content for the[Chip](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/material/Chip). Any previously added content will be overridden.  

### setHorizontalAlignment

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

```
fun setHorizontalAlignment(horizontalAlignment: Int): Chip.Builder
```

Sets the horizontal alignment in the chip. It is strongly recommended that the content of the chip is start-aligned if there is more than primary text in it. By default,[HORIZONTAL_ALIGN_CENTER](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/LayoutElementBuilders#HORIZONTAL_ALIGN_CENTER())will be used when only a primary label is present. Otherwise[HORIZONTAL_ALIGN_START](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/LayoutElementBuilders#HORIZONTAL_ALIGN_START())will be used.  

### setIconContent

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

```
fun setIconContent(imageResourceId: String): Chip.Builder
```

Sets the icon for the[Chip](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/material/Chip). Any previously added custom content will be overridden. Provided icon will be tinted to the given content color from[ChipColors](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/material/ChipColors). This icon should be image with chosen alpha channel and not an actual image. If icon is set, primary label must be set too with[setPrimaryLabelContent](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/material/Chip.Builder#setPrimaryLabelContent(java.lang.String)).  

### setPrimaryLabelContent

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

```
fun setPrimaryLabelContent(primaryLabel: String): Chip.Builder
```

Sets the primary label for the[Chip](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/material/Chip). Any previously added custom content will be overridden. Primary label can be on 1 or 2 lines, depending on the length and existence of secondary label.  

### setSecondaryLabelContent

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

```
fun setSecondaryLabelContent(secondaryLabel: String): Chip.Builder
```

Sets the secondary label for the[Chip](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/material/Chip). Any previously added custom content will be overridden. If secondary label is set, primary label must be set too with[setPrimaryLabelContent](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/material/Chip.Builder#setPrimaryLabelContent(java.lang.String)).  

### setWidth

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

```
fun setWidth(width: DimensionBuilders.ContainerDimension): Chip.Builder
```

Sets the width of[Chip](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/material/Chip). If not set, default value will be set to fill the screen.  

### setWidth

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

```
fun setWidth(width: @Dimension(unit = 0) Float): Chip.Builder
```

Sets the width of[Chip](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/material/Chip). If not set, default value will be set to fill the screen.