# CompactChip.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/CompactChip.java+class:androidx.wear.protolayout.material.CompactChip.Builder) Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/wear-protolayout#1.0.0)

*** ** * ** ***


```
public final class CompactChip.Builder
```

<br />

*** ** * ** ***

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

## Summary

| ### Public constructors |
|---|
| `https://developer.android.com/reference/androidx/wear/protolayout/material/CompactChip.Builder#Builder(android.content.Context,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/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/CompactChip` with associated action. |
| `https://developer.android.com/reference/androidx/wear/protolayout/material/CompactChip.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/CompactChip` 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/CompactChip` | `https://developer.android.com/reference/androidx/wear/protolayout/material/CompactChip.Builder#build()()` Constructs and returns `https://developer.android.com/reference/androidx/wear/protolayout/material/CompactChip` 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/CompactChip.Builder` | `https://developer.android.com/reference/androidx/wear/protolayout/material/CompactChip.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/CompactChip`. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/wear/protolayout/material/CompactChip.Builder` | `https://developer.android.com/reference/androidx/wear/protolayout/material/CompactChip.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/CompactChip`. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/wear/protolayout/material/CompactChip.Builder` | `https://developer.android.com/reference/androidx/wear/protolayout/material/CompactChip.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/CompactChip`. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/wear/protolayout/material/CompactChip.Builder` | `https://developer.android.com/reference/androidx/wear/protolayout/material/CompactChip.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/CompactChip`. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/wear/protolayout/material/CompactChip.Builder` | `https://developer.android.com/reference/androidx/wear/protolayout/material/CompactChip.Builder#setTextContent(java.lang.String)(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/lang/String.html text)` Sets the text for the `https://developer.android.com/reference/androidx/wear/protolayout/material/CompactChip`. |

## Public constructors

### Builder

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

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

Creates a builder for the `https://developer.android.com/reference/androidx/wear/protolayout/material/CompactChip` with associated action. Please add text, icon or both content with `https://developer.android.com/reference/androidx/wear/protolayout/material/CompactChip.Builder#setTextContent(java.lang.String)` and `https://developer.android.com/reference/androidx/wear/protolayout/material/CompactChip.Builder#setIconContent(java.lang.String)`.

| 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/androidx/wear/protolayout/ModifiersBuilders.Clickable clickable` | Associated `https://developer.android.com/reference/androidx/wear/protolayout/ModifiersBuilders.Clickable` for click events. When the CompactChip 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. |

### 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/CompactChip` 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 compact chip. |
| `@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 CompactChip 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 CompactChip build()
```

Constructs and returns `https://developer.android.com/reference/androidx/wear/protolayout/material/CompactChip` 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 CompactChip.Builder setChipColors(@NonNull ChipColors chipColors)
```

Sets the colors for the `https://developer.android.com/reference/androidx/wear/protolayout/material/CompactChip`. 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#COMPACT_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 CompactChip.Builder setContentDescription(@NonNull CharSequence contentDescription)
```

Sets the static content description for the `https://developer.android.com/reference/androidx/wear/protolayout/material/CompactChip`. 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 CompactChip.Builder setContentDescription(
    @NonNull TypeBuilders.StringProp contentDescription
)
```

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

### setIconContent

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

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

Sets the icon for the `https://developer.android.com/reference/androidx/wear/protolayout/material/CompactChip`. 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.

### setTextContent

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

```
public @NonNull CompactChip.Builder setTextContent(@NonNull String text)
```

Sets the text for the `https://developer.android.com/reference/androidx/wear/protolayout/material/CompactChip`.