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

*** ** * ** ***


```
public class Text implements LayoutElementBuilders.LayoutElement
```

<br />

*** ** * ** ***

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

Tiles component `https://developer.android.com/reference/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/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.:

```
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/androidx/wear/tiles/material/Text` object from any layout element, `https://developer.android.com/reference/androidx/wear/tiles/material/Text#fromLayoutElement(androidx.wear.tiles.LayoutElementBuilders.LayoutElement)` method should be used, i.e.:

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

## Summary

| ### Nested types |
|---|
| `public final class https://developer.android.com/reference/androidx/wear/tiles/material/Text.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/Text` | `[fromLayoutElement](https://developer.android.com/reference/androidx/wear/tiles/material/Text#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/ColorBuilders.ColorProp` | `[getColor](https://developer.android.com/reference/androidx/wear/tiles/material/Text#getColor())()` **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/LayoutElementBuilders.FontStyle` | `[getFontStyle](https://developer.android.com/reference/androidx/wear/tiles/material/Text#getFontStyle())()` **This method is deprecated.** Deprecated in Java |
| `float` | `[getLineHeight](https://developer.android.com/reference/androidx/wear/tiles/material/Text#getLineHeight())()` **This method is deprecated.** Deprecated in Java |
| `int` | `[getMaxLines](https://developer.android.com/reference/androidx/wear/tiles/material/Text#getMaxLines())()` **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.Modifiers` | `[getModifiers](https://developer.android.com/reference/androidx/wear/tiles/material/Text#getModifiers())()` **This method is deprecated.** Deprecated in Java |
| `int` | `[getMultilineAlignment](https://developer.android.com/reference/androidx/wear/tiles/material/Text#getMultilineAlignment())()` **This method is deprecated.** Deprecated in Java |
| `int` | `[getOverflow](https://developer.android.com/reference/androidx/wear/tiles/material/Text#getOverflow())()` **This method is deprecated.** Deprecated in Java |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/lang/String.html` | `[getText](https://developer.android.com/reference/androidx/wear/tiles/material/Text#getText())()` **This method is deprecated.** Deprecated in Java |
| `int` | `[getWeight](https://developer.android.com/reference/androidx/wear/tiles/material/Text#getWeight())()` **This method is deprecated.** Deprecated in Java |
| `boolean` | `[isItalic](https://developer.android.com/reference/androidx/wear/tiles/material/Text#isItalic())()` **This method is deprecated.** Deprecated in Java |
| `boolean` | `[isUnderline](https://developer.android.com/reference/androidx/wear/tiles/material/Text#isUnderline())()` **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 Text [fromLayoutElement](https://developer.android.com/reference/androidx/wear/tiles/material/Text#fromLayoutElement(androidx.wear.tiles.LayoutElementBuilders.LayoutElement))(@NonNull LayoutElementBuilders.LayoutElement element)
```

> [!CAUTION]
> **This method 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)

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

> [!CAUTION]
> **This method 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)

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

> [!CAUTION]
> **This method 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)

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

> [!CAUTION]
> **This method 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)

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

> [!CAUTION]
> **This method 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)

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

> [!CAUTION]
> **This method 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)

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

> [!CAUTION]
> **This method 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)

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

> [!CAUTION]
> **This method 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)

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

> [!CAUTION]
> **This method 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)

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

> [!CAUTION]
> **This method 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)

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

> [!CAUTION]
> **This method 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)

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

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

Returns whether the Text is underlined.