# Text

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/Text.java+class:androidx.wear.tiles.material.Text) 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)

*** ** * ** ***


```
class Text : LayoutElementBuilders.LayoutElement
```

<br />

*** ** * ** ***

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

Tiles component `https://developer.android.com/reference/kotlin/androidx/wear/tiles/material/Text` that represents text object holding any information.

There are pre-built typography styles that can be obtained from constants in `https://developer.android.com/reference/kotlin/androidx/wear/tiles/LayoutElementBuilders.FontStyle`.

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
Text text = new Text...
Box box = new Box.Builder().addContent(text).build();

Text myText = (Text) box.getContents().get(0);
```
will fail.

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

```kotlin
Text myText = Text.fromLayoutElement(box.getContents().get(0));
```

## Summary

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

| ### Public functions |
|---|---|
| `java-static https://developer.android.com/reference/kotlin/androidx/wear/tiles/material/Text?` | `[fromLayoutElement](https://developer.android.com/reference/kotlin/androidx/wear/tiles/material/Text#fromLayoutElement(androidx.wear.tiles.LayoutElementBuilders.LayoutElement))(element: https://developer.android.com/reference/kotlin/androidx/wear/tiles/LayoutElementBuilders.LayoutElement)` **This function is deprecated.** Deprecated in Java |
| `https://developer.android.com/reference/kotlin/androidx/wear/tiles/ColorBuilders.ColorProp` | `[getColor](https://developer.android.com/reference/kotlin/androidx/wear/tiles/material/Text#getColor())()` **This function is deprecated.** Deprecated in Java |
| `https://developer.android.com/reference/kotlin/androidx/wear/tiles/LayoutElementBuilders.FontStyle` | `[getFontStyle](https://developer.android.com/reference/kotlin/androidx/wear/tiles/material/Text#getFontStyle())()` **This function is deprecated.** Deprecated in Java |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` | `[getLineHeight](https://developer.android.com/reference/kotlin/androidx/wear/tiles/material/Text#getLineHeight())()` **This function is deprecated.** Deprecated in Java |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `[getMaxLines](https://developer.android.com/reference/kotlin/androidx/wear/tiles/material/Text#getMaxLines())()` **This function is deprecated.** Deprecated in Java |
| `https://developer.android.com/reference/kotlin/androidx/wear/tiles/ModifiersBuilders.Modifiers` | `[getModifiers](https://developer.android.com/reference/kotlin/androidx/wear/tiles/material/Text#getModifiers())()` **This function is deprecated.** Deprecated in Java |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `[getMultilineAlignment](https://developer.android.com/reference/kotlin/androidx/wear/tiles/material/Text#getMultilineAlignment())()` **This function is deprecated.** Deprecated in Java |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `[getOverflow](https://developer.android.com/reference/kotlin/androidx/wear/tiles/material/Text#getOverflow())()` **This function is deprecated.** Deprecated in Java |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html` | `[getText](https://developer.android.com/reference/kotlin/androidx/wear/tiles/material/Text#getText())()` **This function is deprecated.** Deprecated in Java |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `[getWeight](https://developer.android.com/reference/kotlin/androidx/wear/tiles/material/Text#getWeight())()` **This function is deprecated.** Deprecated in Java |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `[isItalic](https://developer.android.com/reference/kotlin/androidx/wear/tiles/material/Text#isItalic())()` **This function is deprecated.** Deprecated in Java |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `[isUnderline](https://developer.android.com/reference/kotlin/androidx/wear/tiles/material/Text#isUnderline())()` **This function is deprecated.** Deprecated in Java |

## Public functions

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

```
java-static fun [fromLayoutElement](https://developer.android.com/reference/kotlin/androidx/wear/tiles/material/Text#fromLayoutElement(androidx.wear.tiles.LayoutElementBuilders.LayoutElement))(element: LayoutElementBuilders.LayoutElement): Text?
```

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

Returns Material Text 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 Material Text. Otherwise, it will return null.

### getColor

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)

```
fun [getColor](https://developer.android.com/reference/kotlin/androidx/wear/tiles/material/Text#getColor())(): ColorBuilders.ColorProp
```

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

Returns the color of this Text element.

### getFontStyle

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)

```
fun [getFontStyle](https://developer.android.com/reference/kotlin/androidx/wear/tiles/material/Text#getFontStyle())(): LayoutElementBuilders.FontStyle
```

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

Returns the font style of this Text element.

### getLineHeight

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)

```
fun [getLineHeight](https://developer.android.com/reference/kotlin/androidx/wear/tiles/material/Text#getLineHeight())(): Float
```

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

Returns the line height of this Text element.

### getMaxLines

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)

```
fun [getMaxLines](https://developer.android.com/reference/kotlin/androidx/wear/tiles/material/Text#getMaxLines())(): Int
```

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

Returns the max lines of text of this Text element.

### getModifiers

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)

```
fun [getModifiers](https://developer.android.com/reference/kotlin/androidx/wear/tiles/material/Text#getModifiers())(): ModifiersBuilders.Modifiers
```

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

Returns the modifiers of this Text element.

### getMultilineAlignment

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)

```
fun [getMultilineAlignment](https://developer.android.com/reference/kotlin/androidx/wear/tiles/material/Text#getMultilineAlignment())(): Int
```

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

Returns the multiline alignment of this Text element.

### getOverflow

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)

```
fun [getOverflow](https://developer.android.com/reference/kotlin/androidx/wear/tiles/material/Text#getOverflow())(): Int
```

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

Returns the overflow of this Text element.

### getText

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)

```
fun [getText](https://developer.android.com/reference/kotlin/androidx/wear/tiles/material/Text#getText())(): String
```

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

Returns the text of this Text element.

### getWeight

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)

```
fun [getWeight](https://developer.android.com/reference/kotlin/androidx/wear/tiles/material/Text#getWeight())(): Int
```

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

Returns the overflow of this Text element.

### isItalic

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)

```
fun [isItalic](https://developer.android.com/reference/kotlin/androidx/wear/tiles/material/Text#isItalic())(): Boolean
```

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

Returns whether the Text is in italic.

### isUnderline

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)

```
fun [isUnderline](https://developer.android.com/reference/kotlin/androidx/wear/tiles/material/Text#isUnderline())(): Boolean
```

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

Returns whether the Text is underlined.