# Chip

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

*** ** * ** ***


```
public class Chip implements LayoutElementBuilders.LayoutElement
```

<br />

*** ** * ** ***

> [!CAUTION]
> **This class is deprecated.**   
>
> Use the new class `https://developer.android.com/reference/androidx/wear/protolayout/material/Chip` which provides the same API and functionality.

Tiles component `https://developer.android.com/reference/androidx/wear/tiles/material/Chip` that represents clickable object with the text, optional label and optional icon or with custom content.

The Chip is Stadium shape and has a max height designed to take no more than two lines of text of `https://developer.android.com/reference/androidx/wear/tiles/material/Typography#TYPOGRAPHY_BUTTON()` style. The `https://developer.android.com/reference/androidx/wear/tiles/material/Chip` can have an icon horizontally parallel to the two lines of text. Width of chip can very, and the recommended size is screen dependent with the recommended margin being applied.

The recommended set of `https://developer.android.com/reference/androidx/wear/tiles/material/ChipColors` styles can be obtained from `https://developer.android.com/reference/androidx/wear/tiles/material/ChipDefaults`., e.g. `https://developer.android.com/reference/androidx/wear/tiles/material/ChipDefaults#PRIMARY_COLORS()` to get a color scheme for a primary `https://developer.android.com/reference/androidx/wear/tiles/material/Chip`.

When accessing the contents of a container for testing, note that this element can't be simply casted back to the original type, i.e.:

```
Chip chip = new Chip...
Box box = new Box.Builder().addContent(chip).build();

Chip myChip = (Chip) box.getContents().get(0);
```
will fail.

To be able to get `https://developer.android.com/reference/androidx/wear/tiles/material/Chip` object from any layout element, `https://developer.android.com/reference/androidx/wear/tiles/material/Chip#fromLayoutElement(androidx.wear.tiles.LayoutElementBuilders.LayoutElement)` method should be used, i.e.:

```
Chip myChip = Chip.fromLayoutElement(box.getContents().get(0));
```

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/wear/tiles/material/layouts/PrimaryLayout.Builder#setContent(androidx.wear.tiles.LayoutElementBuilders.LayoutElement)` | if this Chip is used inside of `https://developer.android.com/reference/androidx/wear/tiles/material/layouts/PrimaryLayout`. |

## Summary

| ### Nested types |
|---|
| `public final class https://developer.android.com/reference/androidx/wear/tiles/material/Chip.Builder implements https://developer.android.com/reference/androidx/wear/tiles/LayoutElementBuilders.LayoutElement.Builder` **This class is deprecated.** Deprecated in Java |

| ### Public methods |
|---|---|
| `static @https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/androidx/wear/tiles/material/Chip` | `[fromLayoutElement](https://developer.android.com/reference/androidx/wear/tiles/material/Chip#fromLayoutElement(androidx.wear.tiles.LayoutElementBuilders.LayoutElement))(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/wear/tiles/LayoutElementBuilders.LayoutElement element)` **This method is deprecated.** Deprecated in Java |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/wear/tiles/material/ChipColors` | `[getChipColors](https://developer.android.com/reference/androidx/wear/tiles/material/Chip#getChipColors())()` **This method is deprecated.** Deprecated in Java |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/wear/tiles/ModifiersBuilders.Clickable` | `[getClickable](https://developer.android.com/reference/androidx/wear/tiles/material/Chip#getClickable())()` **This method is deprecated.** Deprecated in Java |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/java/lang/CharSequence.html` | `[getContentDescription](https://developer.android.com/reference/androidx/wear/tiles/material/Chip#getContentDescription())()` **This method is deprecated.** Deprecated in Java |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/androidx/wear/tiles/LayoutElementBuilders.LayoutElement` | `[getCustomContent](https://developer.android.com/reference/androidx/wear/tiles/material/Chip#getCustomContent())()` **This method is deprecated.** Deprecated in Java |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/wear/tiles/DimensionBuilders.ContainerDimension` | `[getHeight](https://developer.android.com/reference/androidx/wear/tiles/material/Chip#getHeight())()` **This method is deprecated.** Deprecated in Java |
| `int` | `[getHorizontalAlignment](https://developer.android.com/reference/androidx/wear/tiles/material/Chip#getHorizontalAlignment())()` **This method is deprecated.** Deprecated in Java |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/java/lang/String.html` | `[getIconContent](https://developer.android.com/reference/androidx/wear/tiles/material/Chip#getIconContent())()` **This method is deprecated.** Deprecated in Java |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/java/lang/String.html` | `[getPrimaryLabelContent](https://developer.android.com/reference/androidx/wear/tiles/material/Chip#getPrimaryLabelContent())()` **This method is deprecated.** Deprecated in Java |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/java/lang/String.html` | `[getSecondaryLabelContent](https://developer.android.com/reference/androidx/wear/tiles/material/Chip#getSecondaryLabelContent())()` **This method is deprecated.** Deprecated in Java |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/wear/tiles/DimensionBuilders.ContainerDimension` | `[getWidth](https://developer.android.com/reference/androidx/wear/tiles/material/Chip#getWidth())()` **This method is deprecated.** Deprecated in Java |

## Public methods

### fromLayoutElement

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

```
public static @Nullable Chip [fromLayoutElement](https://developer.android.com/reference/androidx/wear/tiles/material/Chip#fromLayoutElement(androidx.wear.tiles.LayoutElementBuilders.LayoutElement))(@NonNull LayoutElementBuilders.LayoutElement element)
```

> [!CAUTION]
> **This method is deprecated.**   
> Deprecated in Java

Returns Chip object from the given androidx.wear.tiles.LayoutElementBuilders.LayoutElement (e.g. one retrieved from a container's content with `
container.getContents().get(index)`) if that element can be converted to Chip. Otherwise, it will return null.

### getChipColors

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

```
public @NonNull ChipColors [getChipColors](https://developer.android.com/reference/androidx/wear/tiles/material/Chip#getChipColors())()
```

> [!CAUTION]
> **This method is deprecated.**   
> Deprecated in Java

Returns chip colors of this Chip.

### getClickable

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

```
public @NonNull ModifiersBuilders.Clickable [getClickable](https://developer.android.com/reference/androidx/wear/tiles/material/Chip#getClickable())()
```

> [!CAUTION]
> **This method is deprecated.**   
> Deprecated in Java

Returns click event action associated with this Chip.

### getContentDescription

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

```
public @Nullable CharSequence [getContentDescription](https://developer.android.com/reference/androidx/wear/tiles/material/Chip#getContentDescription())()
```

> [!CAUTION]
> **This method is deprecated.**   
> Deprecated in Java

Returns content description of this Chip.

### getCustomContent

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

```
public @Nullable LayoutElementBuilders.LayoutElement [getCustomContent](https://developer.android.com/reference/androidx/wear/tiles/material/Chip#getCustomContent())()
```

> [!CAUTION]
> **This method is deprecated.**   
> Deprecated in Java

Returns custom content from this Chip if it has been added. Otherwise, it returns null.

### getHeight

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

```
public @NonNull DimensionBuilders.ContainerDimension [getHeight](https://developer.android.com/reference/androidx/wear/tiles/material/Chip#getHeight())()
```

> [!CAUTION]
> **This method is deprecated.**   
> Deprecated in Java

Returns height of this Chip.

### getHorizontalAlignment

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

```
public int [getHorizontalAlignment](https://developer.android.com/reference/androidx/wear/tiles/material/Chip#getHorizontalAlignment())()
```

> [!CAUTION]
> **This method is deprecated.**   
> Deprecated in Java

Returns the horizontal alignment of the content in this Chip.

### getIconContent

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

```
public @Nullable String [getIconContent](https://developer.android.com/reference/androidx/wear/tiles/material/Chip#getIconContent())()
```

> [!CAUTION]
> **This method is deprecated.**   
> Deprecated in Java

Returns icon id from this Chip if it has been added. Otherwise, it returns null.

### getPrimaryLabelContent

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

```
public @Nullable String [getPrimaryLabelContent](https://developer.android.com/reference/androidx/wear/tiles/material/Chip#getPrimaryLabelContent())()
```

> [!CAUTION]
> **This method is deprecated.**   
> Deprecated in Java

Returns primary label from this Chip if it has been added. Otherwise, it returns null.

### getSecondaryLabelContent

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

```
public @Nullable String [getSecondaryLabelContent](https://developer.android.com/reference/androidx/wear/tiles/material/Chip#getSecondaryLabelContent())()
```

> [!CAUTION]
> **This method is deprecated.**   
> Deprecated in Java

Returns secondary label from this Chip if it has been added. Otherwise, it returns null.

### getWidth

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

```
public @NonNull DimensionBuilders.ContainerDimension [getWidth](https://developer.android.com/reference/androidx/wear/tiles/material/Chip#getWidth())()
```

> [!CAUTION]
> **This method is deprecated.**   
> Deprecated in Java

Returns width of this Chip.