# Button

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/Button.java+class:androidx.wear.tiles.material.Button) 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 Button : LayoutElementBuilders.LayoutElement
```

<br />

*** ** * ** ***

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

Tiles component `https://developer.android.com/reference/kotlin/androidx/wear/tiles/material/Button` that represents clickable button with the given content.

The Button is circular in shape. The recommended sizes are defined in `https://developer.android.com/reference/kotlin/androidx/wear/tiles/material/ButtonDefaults`.

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

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

Button myButton = (Button) box.getContents().get(0);
```
will fail.

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

```kotlin
Button myButton = Button.fromLayoutElement(box.getContents().get(0));
```

## Summary

| ### Nested types |
|---|
| `class https://developer.android.com/reference/kotlin/androidx/wear/tiles/material/Button.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/Button?` | `[fromLayoutElement](https://developer.android.com/reference/kotlin/androidx/wear/tiles/material/Button#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/material/ButtonColors` | `[getButtonColors](https://developer.android.com/reference/kotlin/androidx/wear/tiles/material/Button#getButtonColors())()` **This function is deprecated.** Deprecated in Java |
| `https://developer.android.com/reference/kotlin/androidx/wear/tiles/ModifiersBuilders.Clickable` | `[getClickable](https://developer.android.com/reference/kotlin/androidx/wear/tiles/material/Button#getClickable())()` **This function is deprecated.** Deprecated in Java |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-char-sequence/index.html?` | `[getContentDescription](https://developer.android.com/reference/kotlin/androidx/wear/tiles/material/Button#getContentDescription())()` **This function is deprecated.** Deprecated in Java |
| `https://developer.android.com/reference/kotlin/androidx/wear/tiles/LayoutElementBuilders.LayoutElement?` | `[getCustomContent](https://developer.android.com/reference/kotlin/androidx/wear/tiles/material/Button#getCustomContent())()` **This function is deprecated.** Deprecated in Java |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html?` | `[getIconContent](https://developer.android.com/reference/kotlin/androidx/wear/tiles/material/Button#getIconContent())()` **This function is deprecated.** Deprecated in Java |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html?` | `[getImageContent](https://developer.android.com/reference/kotlin/androidx/wear/tiles/material/Button#getImageContent())()` **This function is deprecated.** Deprecated in Java |
| `https://developer.android.com/reference/kotlin/androidx/wear/tiles/DimensionBuilders.ContainerDimension` | `[getSize](https://developer.android.com/reference/kotlin/androidx/wear/tiles/material/Button#getSize())()` **This function is deprecated.** Deprecated in Java |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html?` | `[getTextContent](https://developer.android.com/reference/kotlin/androidx/wear/tiles/material/Button#getTextContent())()` **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/Button#fromLayoutElement(androidx.wear.tiles.LayoutElementBuilders.LayoutElement))(element: LayoutElementBuilders.LayoutElement): Button?
```

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

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

### getButtonColors

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 [getButtonColors](https://developer.android.com/reference/kotlin/androidx/wear/tiles/material/Button#getButtonColors())(): ButtonColors
```

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

Returns button color of this Button.

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

```
fun [getClickable](https://developer.android.com/reference/kotlin/androidx/wear/tiles/material/Button#getClickable())(): ModifiersBuilders.Clickable
```

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

Returns click event action associated with this Button.

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

```
fun [getContentDescription](https://developer.android.com/reference/kotlin/androidx/wear/tiles/material/Button#getContentDescription())(): CharSequence?
```

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

Returns content description for this Button.

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

```
fun [getCustomContent](https://developer.android.com/reference/kotlin/androidx/wear/tiles/material/Button#getCustomContent())(): LayoutElementBuilders.LayoutElement?
```

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

Returns the custom content of this Button if it has been added. Otherwise, it returns null.

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

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

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

Returns the icon content of this Button if it has been added. Otherwise, it returns null.

### getImageContent

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 [getImageContent](https://developer.android.com/reference/kotlin/androidx/wear/tiles/material/Button#getImageContent())(): String?
```

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

Returns the image content of this Button if it has been added. Otherwise, it returns null.

### getSize

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 [getSize](https://developer.android.com/reference/kotlin/androidx/wear/tiles/material/Button#getSize())(): DimensionBuilders.ContainerDimension
```

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

Returns size for this Button.

### getTextContent

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 [getTextContent](https://developer.android.com/reference/kotlin/androidx/wear/tiles/material/Button#getTextContent())(): String?
```

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

Returns the text content of this Button if it has been added. Otherwise, it returns null.