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

*** ** * ** ***


```
public class Button implements LayoutElementBuilders.LayoutElement
```

<br />

*** ** * ** ***

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

Tiles component `https://developer.android.com/reference/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/androidx/wear/tiles/material/ButtonDefaults`.

The recommended set of `https://developer.android.com/reference/androidx/wear/tiles/material/ButtonColors` styles can be obtained from `https://developer.android.com/reference/androidx/wear/tiles/material/ButtonDefaults`., e.g. `https://developer.android.com/reference/androidx/wear/tiles/material/ButtonDefaults#PRIMARY_COLORS()` to get a color scheme for a primary `https://developer.android.com/reference/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.:

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

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

## Summary

| ### Nested types |
|---|
| `public final class https://developer.android.com/reference/androidx/wear/tiles/material/Button.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/Button` | `[fromLayoutElement](https://developer.android.com/reference/androidx/wear/tiles/material/Button#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/ButtonColors` | `[getButtonColors](https://developer.android.com/reference/androidx/wear/tiles/material/Button#getButtonColors())()` **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/Button#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/Button#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/Button#getCustomContent())()` **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/Button#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` | `[getImageContent](https://developer.android.com/reference/androidx/wear/tiles/material/Button#getImageContent())()` **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` | `[getSize](https://developer.android.com/reference/androidx/wear/tiles/material/Button#getSize())()` **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` | `[getTextContent](https://developer.android.com/reference/androidx/wear/tiles/material/Button#getTextContent())()` **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 Button [fromLayoutElement](https://developer.android.com/reference/androidx/wear/tiles/material/Button#fromLayoutElement(androidx.wear.tiles.LayoutElementBuilders.LayoutElement))(@NonNull LayoutElementBuilders.LayoutElement element)
```

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

```
public @NonNull ButtonColors [getButtonColors](https://developer.android.com/reference/androidx/wear/tiles/material/Button#getButtonColors())()
```

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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