# MultiButtonLayout

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

<br />

*** ** * ** ***

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

Opinionated Tiles layout, that can contain between 1 and `https://developer.android.com/reference/androidx/wear/tiles/material/layouts/LayoutDefaults#MULTI_BUTTON_MAX_NUMBER()` number of buttons arranged inline with the Material guidelines. Can be used as a content passed in to the `https://developer.android.com/reference/androidx/wear/tiles/material/layouts/PrimaryLayout`, but if there is `https://developer.android.com/reference/androidx/wear/tiles/material/layouts/LayoutDefaults#MULTI_BUTTON_MAX_NUMBER()` buttons it should be used on its own.

For additional examples and suggested layouts see [Tiles Design System](https://developer.android.com/training/wearables/design/tiles-design-system).

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

```
MultiButtonLayout mbl = new MultiButtonLayout...
Box box = new Box.Builder().addContent(mbl).build();

MultiButtonLayout myMbl = (MultiButtonLayout) box.getContents().get(0);
```
will fail.

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

```
MultiButtonLayout myMbl = MultiButtonLayout.fromLayoutElement(box.getContents().get(0));
```

## Summary

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

| ### Constants |
|---|---|
| `static final int` | `https://developer.android.com/reference/androidx/wear/tiles/material/layouts/MultiButtonLayout#FIVE_BUTTON_DISTRIBUTION_BOTTOM_HEAVY() = 2` **This field is deprecated.** Deprecated in Java |
| `static final int` | `https://developer.android.com/reference/androidx/wear/tiles/material/layouts/MultiButtonLayout#FIVE_BUTTON_DISTRIBUTION_TOP_HEAVY() = 1` **This field 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/layouts/MultiButtonLayout` | `[fromLayoutElement](https://developer.android.com/reference/androidx/wear/tiles/material/layouts/MultiButtonLayout#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/java/util/List.html<https://developer.android.com/reference/androidx/wear/tiles/LayoutElementBuilders.LayoutElement>` | `[getButtonContents](https://developer.android.com/reference/androidx/wear/tiles/material/layouts/MultiButtonLayout#getButtonContents())()` **This method is deprecated.** Deprecated in Java |
| `int` | `[getFiveButtonDistribution](https://developer.android.com/reference/androidx/wear/tiles/material/layouts/MultiButtonLayout#getFiveButtonDistribution())()` **This method is deprecated.** Deprecated in Java |

## Constants

### FIVE_BUTTON_DISTRIBUTION_BOTTOM_HEAVY

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 final int FIVE_BUTTON_DISTRIBUTION_BOTTOM_HEAVY = 2
```

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

Button distribution where the last row has more buttons than other rows.

### FIVE_BUTTON_DISTRIBUTION_TOP_HEAVY

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 final int FIVE_BUTTON_DISTRIBUTION_TOP_HEAVY = 1
```

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

Button distribution where the first row has more buttons than other rows.

## 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 MultiButtonLayout [fromLayoutElement](https://developer.android.com/reference/androidx/wear/tiles/material/layouts/MultiButtonLayout#fromLayoutElement(androidx.wear.tiles.LayoutElementBuilders.LayoutElement))(@NonNull LayoutElementBuilders.LayoutElement element)
```

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

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

### getButtonContents

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 List<LayoutElementBuilders.LayoutElement> [getButtonContents](https://developer.android.com/reference/androidx/wear/tiles/material/layouts/MultiButtonLayout#getButtonContents())()
```

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

Gets the content from this layout, containing all buttons that were added.

### getFiveButtonDistribution

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 [getFiveButtonDistribution](https://developer.android.com/reference/androidx/wear/tiles/material/layouts/MultiButtonLayout#getFiveButtonDistribution())()
```

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

Gets the button distribution from this layout for the case when there is 5 buttons in the layout. If there is more or less buttons than 5, default `https://developer.android.com/reference/androidx/wear/tiles/material/layouts/MultiButtonLayout#FIVE_BUTTON_DISTRIBUTION_BOTTOM_HEAVY()` will be returned.