# TitleChip.Builder

# TitleChip.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/TitleChip.java+class:androidx.wear.protolayout.material.TitleChip.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/TitleChip.Builder "View this page in Java")

<br />

```
class TitleChip.Builder
```

<br />

*** ** * ** ***

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

## Summary

|                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               ### Public constructors                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               |
|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [Builder](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/material/TitleChip.Builder#Builder(android.content.Context,java.lang.String,androidx.wear.protolayout.ModifiersBuilders.Clickable,androidx.wear.protolayout.DeviceParametersBuilders.DeviceParameters))`(` ` context: `[Context](https://developer.android.com/reference/android/content/Context.html)`,` ` text: `[String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.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[TitleChip](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/material/TitleChip)with associated action and the given text |

|                                                   ### Public functions                                                   |
|--------------------------------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [TitleChip](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/material/TitleChip)                 | [build](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/material/TitleChip.Builder#build())`()` Constructs and returns[TitleChip](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/material/TitleChip)with the provided content and look.                                                                                                                                                                                                               |
| [TitleChip.Builder](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/material/TitleChip.Builder) | [setChipColors](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/material/TitleChip.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[TitleChip](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/material/TitleChip).                                                           |
| [TitleChip.Builder](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/material/TitleChip.Builder) | [setContentDescription](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/material/TitleChip.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[TitleChip](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/material/TitleChip).                                                  |
| [TitleChip.Builder](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/material/TitleChip.Builder) | [setContentDescription](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/material/TitleChip.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[TitleChip](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/material/TitleChip). |
| [TitleChip.Builder](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/material/TitleChip.Builder) | [setHorizontalAlignment](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/material/TitleChip.Builder#setHorizontalAlignment(int))`(horizontalAlignment: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`)` Sets the horizontal alignment in the chip.                                                                                                                                                                                               |
| [TitleChip.Builder](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/material/TitleChip.Builder) | [setIconContent](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/material/TitleChip.Builder#setIconContent(java.lang.String))`(imageResourceId: `[String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)`)` Sets the icon for the[TitleChip](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/material/TitleChip).                                                                                                            |
| [TitleChip.Builder](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/material/TitleChip.Builder) | [setWidth](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/material/TitleChip.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[TitleChip](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/material/TitleChip).                    |
| [TitleChip.Builder](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/material/TitleChip.Builder) | [setWidth](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/material/TitleChip.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[TitleChip](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/material/TitleChip).                                            |

## Public constructors

### Builder

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

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

Creates a builder for the[TitleChip](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/material/TitleChip)with associated action and the given text  

|                                                                                     Parameters                                                                                      |
|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `context: `[Context](https://developer.android.com/reference/android/content/Context.html)                                                                                          | The application's context.                                                                                                                                                                                     |
| `text: `[String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)                                                                                           | The text to be displayed in this title chip. Text will be displayed in 1 line and truncated if it doesn't fit.                                                                                                 |
| `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 TitleChip 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 for styling text.                                                                                                                                                                   |

## Public functions

### build

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

```
fun build(): TitleChip
```

Constructs and returns[TitleChip](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/material/TitleChip)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): TitleChip.Builder
```

Sets the colors for the[TitleChip](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/material/TitleChip). If set,[getBackgroundColor](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/material/ChipColors#getBackgroundColor())will be used for the background of the button and[getContentColor](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/material/ChipColors#getContentColor())for the text. If not set,[TITLE_PRIMARY_COLORS](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/material/ChipDefaults#TITLE_PRIMARY_COLORS())will be used.  

### setContentDescription

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

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

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

### setContentDescription

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

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

Sets the content description for the[TitleChip](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/material/TitleChip). It is highly recommended to provide this for chip containing an 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).  

### setHorizontalAlignment

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

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

Sets the horizontal alignment in the chip. If not set, content will be centered.  

### setIconContent

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

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

Sets the icon for the[TitleChip](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/material/TitleChip). 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 that can be tinted.  

### setWidth

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

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

Sets the width of[TitleChip](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/material/TitleChip). 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): TitleChip.Builder
```

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