# TitleChip

# TitleChip

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)  
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 "View this page in Java")

<br />

```
class TitleChip : LayoutElementBuilders.LayoutElement
```

<br />

*** ** * ** ***

ProtoLayout component[TitleChip](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/material/TitleChip)that represents clickable object with the text.

The Title Chip is Stadium shaped object with a larger height then standard Chip and it will take one line of text of[TYPOGRAPHY_TITLE2](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/material/Typography#TYPOGRAPHY_TITLE2())style.

The recommended set of[ChipColors](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/material/ChipColors)styles can be obtained from[ChipDefaults](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/material/ChipDefaults), e.g.[TITLE_PRIMARY_COLORS](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/material/ChipDefaults#TITLE_PRIMARY_COLORS())to get a color scheme for a primary[TitleChip](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/material/TitleChip).

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.:  

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

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

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

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

|                                                                                                See also                                                                                                 |
|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [setContent](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/material/layouts/PrimaryLayout.Builder#setContent(androidx.wear.protolayout.LayoutElementBuilders.LayoutElement)) | if this TitleChip is used inside of[androidx.wear.protolayout.material.layouts.PrimaryLayout](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/material/layouts/PrimaryLayout). |

## Summary

|                                                                                                                      ### Nested types                                                                                                                       |
|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `class `[TitleChip.Builder](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/material/TitleChip.Builder) Builder class for[TitleChip](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/material/TitleChip). |

|                                                                 ### Public functions                                                                  |
|-------------------------------------------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `java-static `[TitleChip](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/material/TitleChip)`?`                             | [fromLayoutElement](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/material/TitleChip#fromLayoutElement(androidx.wear.protolayout.LayoutElementBuilders.LayoutElement))`(element: `[LayoutElementBuilders.LayoutElement](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/LayoutElementBuilders.LayoutElement)`)` Returns TitleChip object from the given LayoutElement (e.g. one retrieved from a container's content with`container.getContents().get(index)`) if that element can be converted to TitleChip. |
| [ChipColors](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/material/ChipColors)                                            | [getChipColors](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/material/TitleChip#getChipColors())`()` Returns chip color of this Chip.                                                                                                                                                                                                                                                                                                                                                                                                 |
| [ModifiersBuilders.Clickable](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/ModifiersBuilders.Clickable)                   | [getClickable](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/material/TitleChip#getClickable())`()` Returns click event action associated with this Chip.                                                                                                                                                                                                                                                                                                                                                                              |
| [TypeBuilders.StringProp](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/TypeBuilders.StringProp)`?`                        | [getContentDescription](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/material/TitleChip#getContentDescription())`()` Returns content description of this TitleChip.                                                                                                                                                                                                                                                                                                                                                                   |
| [Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)                                                                           | [getHorizontalAlignment](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/material/TitleChip#getHorizontalAlignment())`()` Returns the horizontal alignment of the content in this Chip.                                                                                                                                                                                                                                                                                                                                                  |
| [String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)`?`                                                                  | [getIconContent](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/material/TitleChip#getIconContent())`()` Returns icon id from this TitleChip if it has been added.                                                                                                                                                                                                                                                                                                                                                                      |
| [String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)                                                                     | [getText](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/material/TitleChip#getText())`()` Returns text content of this Chip.                                                                                                                                                                                                                                                                                                                                                                                                           |
| [DimensionBuilders.ContainerDimension](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/DimensionBuilders.ContainerDimension) | [getWidth](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/material/TitleChip#getWidth())`()` Returns width of this Chip.                                                                                                                                                                                                                                                                                                                                                                                                                |

## Public functions

### fromLayoutElement

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

```
java-static fun fromLayoutElement(element: LayoutElementBuilders.LayoutElement): TitleChip?
```

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

### getChipColors

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

```
fun getChipColors(): ChipColors
```

Returns chip color of this Chip.  

### getClickable

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

```
fun getClickable(): ModifiersBuilders.Clickable
```

Returns click event action associated with this Chip.  

### getContentDescription

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

```
fun getContentDescription(): TypeBuilders.StringProp?
```

Returns content description of this TitleChip.  

### getHorizontalAlignment

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

```
fun getHorizontalAlignment(): Int
```

Returns the horizontal alignment of the content in this Chip.  

### getIconContent

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

```
fun getIconContent(): String?
```

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

### getText

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

```
fun getText(): String
```

Returns text content of this Chip.  

### getWidth

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

```
fun getWidth(): DimensionBuilders.ContainerDimension
```

Returns width of this Chip.