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

*** ** * ** ***


```
public final class TitleChip.Builder
```

<br />

*** ** * ** ***

Builder class for `https://developer.android.com/reference/androidx/wear/protolayout/material/TitleChip`.

## Summary

| ### Public constructors |
|---|
| `https://developer.android.com/reference/androidx/wear/protolayout/material/TitleChip.Builder#Builder(android.content.Context,java.lang.String,androidx.wear.protolayout.ModifiersBuilders.Clickable,androidx.wear.protolayout.DeviceParametersBuilders.DeviceParameters)( @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/content/Context.html context, @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/lang/String.html text, @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/wear/protolayout/ModifiersBuilders.Clickable clickable, @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/wear/protolayout/DeviceParametersBuilders.DeviceParameters deviceParameters )` Creates a builder for the `https://developer.android.com/reference/androidx/wear/protolayout/material/TitleChip` with associated action and the given text |

| ### Public methods |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/wear/protolayout/material/TitleChip` | `https://developer.android.com/reference/androidx/wear/protolayout/material/TitleChip.Builder#build()()` Constructs and returns `https://developer.android.com/reference/androidx/wear/protolayout/material/TitleChip` with the provided content and look. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/wear/protolayout/material/TitleChip.Builder` | `https://developer.android.com/reference/androidx/wear/protolayout/material/TitleChip.Builder#setChipColors(androidx.wear.protolayout.material.ChipColors)(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/wear/protolayout/material/ChipColors chipColors)` Sets the colors for the `https://developer.android.com/reference/androidx/wear/protolayout/material/TitleChip`. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/wear/protolayout/material/TitleChip.Builder` | `https://developer.android.com/reference/androidx/wear/protolayout/material/TitleChip.Builder#setContentDescription(java.lang.CharSequence)(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/lang/CharSequence.html contentDescription)` Sets the static content description for the `https://developer.android.com/reference/androidx/wear/protolayout/material/TitleChip`. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/wear/protolayout/material/TitleChip.Builder` | `https://developer.android.com/reference/androidx/wear/protolayout/material/TitleChip.Builder#setContentDescription(androidx.wear.protolayout.TypeBuilders.StringProp)( @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/wear/protolayout/TypeBuilders.StringProp contentDescription )` Sets the content description for the `https://developer.android.com/reference/androidx/wear/protolayout/material/TitleChip`. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/wear/protolayout/material/TitleChip.Builder` | `https://developer.android.com/reference/androidx/wear/protolayout/material/TitleChip.Builder#setHorizontalAlignment(int)(int horizontalAlignment)` Sets the horizontal alignment in the chip. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/wear/protolayout/material/TitleChip.Builder` | `https://developer.android.com/reference/androidx/wear/protolayout/material/TitleChip.Builder#setIconContent(java.lang.String)(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/lang/String.html imageResourceId)` Sets the icon for the `https://developer.android.com/reference/androidx/wear/protolayout/material/TitleChip`. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/wear/protolayout/material/TitleChip.Builder` | `https://developer.android.com/reference/androidx/wear/protolayout/material/TitleChip.Builder#setWidth(androidx.wear.protolayout.DimensionBuilders.ContainerDimension)(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/wear/protolayout/DimensionBuilders.ContainerDimension width)` Sets the width of `https://developer.android.com/reference/androidx/wear/protolayout/material/TitleChip`. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/wear/protolayout/material/TitleChip.Builder` | `https://developer.android.com/reference/androidx/wear/protolayout/material/TitleChip.Builder#setWidth(float)(@https://developer.android.com/reference/androidx/annotation/Dimension(unit = 0) float width)` Sets the width of `https://developer.android.com/reference/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)

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

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

| Parameters |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/content/Context.html context` | The application's context. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/lang/String.html text` | The text to be displayed in this title chip. Text will be displayed in 1 line and truncated if it doesn't fit. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/wear/protolayout/ModifiersBuilders.Clickable clickable` | Associated `https://developer.android.com/reference/androidx/wear/protolayout/ModifiersBuilders.Clickable` for click events. When the TitleChip is clicked it will fire the associated action. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/wear/protolayout/DeviceParametersBuilders.DeviceParameters deviceParameters` | The device parameters used for styling text. |

## Public methods

### build

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

```
public @NonNull TitleChip build()
```

Constructs and returns `https://developer.android.com/reference/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)

```
public @NonNull TitleChip.Builder setChipColors(@NonNull ChipColors chipColors)
```

Sets the colors for the `https://developer.android.com/reference/androidx/wear/protolayout/material/TitleChip`. If set, `https://developer.android.com/reference/androidx/wear/protolayout/material/ChipColors#getBackgroundColor()` will be used for the background of the button and `https://developer.android.com/reference/androidx/wear/protolayout/material/ChipColors#getContentColor()` for the text. If not set, `https://developer.android.com/reference/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)

```
public @NonNull TitleChip.Builder setContentDescription(@NonNull CharSequence contentDescription)
```

Sets the static content description for the `https://developer.android.com/reference/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)

```
public @NonNull TitleChip.Builder setContentDescription(
    @NonNull TypeBuilders.StringProp contentDescription
)
```

Sets the content description for the `https://developer.android.com/reference/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)

```
public @NonNull TitleChip.Builder setHorizontalAlignment(int horizontalAlignment)
```

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)

```
public @NonNull TitleChip.Builder setIconContent(@NonNull String imageResourceId)
```

Sets the icon for the `https://developer.android.com/reference/androidx/wear/protolayout/material/TitleChip`. Provided icon will be tinted to the given content color from `https://developer.android.com/reference/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)

```
public @NonNull TitleChip.Builder setWidth(@NonNull DimensionBuilders.ContainerDimension width)
```

Sets the width of `https://developer.android.com/reference/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)

```
public @NonNull TitleChip.Builder setWidth(@Dimension(unit = 0) float width)
```

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