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

*** ** * ** ***


```
class MultiButtonLayout : LayoutElementBuilders.LayoutElement
```

<br />

*** ** * ** ***

> [!CAUTION]
> **This class is deprecated.**   
>
> Use the new class `https://developer.android.com/reference/kotlin/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/kotlin/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/kotlin/androidx/wear/tiles/material/layouts/PrimaryLayout`, but if there is `https://developer.android.com/reference/kotlin/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.:

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

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

## Summary

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

| ### Constants |
|---|---|
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/wear/tiles/material/layouts/MultiButtonLayout#FIVE_BUTTON_DISTRIBUTION_BOTTOM_HEAVY() = 2` **This property is deprecated.** Deprecated in Java |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/wear/tiles/material/layouts/MultiButtonLayout#FIVE_BUTTON_DISTRIBUTION_TOP_HEAVY() = 1` **This property is deprecated.** Deprecated in Java |

| ### Public functions |
|---|---|
| `java-static https://developer.android.com/reference/kotlin/androidx/wear/tiles/material/layouts/MultiButtonLayout?` | `[fromLayoutElement](https://developer.android.com/reference/kotlin/androidx/wear/tiles/material/layouts/MultiButtonLayout#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://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-mutable-list/index.html)https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html<https://developer.android.com/reference/kotlin/androidx/wear/tiles/LayoutElementBuilders.LayoutElement!>` | `[getButtonContents](https://developer.android.com/reference/kotlin/androidx/wear/tiles/material/layouts/MultiButtonLayout#getButtonContents())()` **This function is deprecated.** Deprecated in Java |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `[getFiveButtonDistribution](https://developer.android.com/reference/kotlin/androidx/wear/tiles/material/layouts/MultiButtonLayout#getFiveButtonDistribution())()` **This function 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)

```
const val FIVE_BUTTON_DISTRIBUTION_BOTTOM_HEAVY = 2: Int
```

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

```
const val FIVE_BUTTON_DISTRIBUTION_TOP_HEAVY = 1: Int
```

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

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

## 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/layouts/MultiButtonLayout#fromLayoutElement(androidx.wear.tiles.LayoutElementBuilders.LayoutElement))(element: LayoutElementBuilders.LayoutElement): MultiButtonLayout?
```

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

```
fun [getButtonContents](https://developer.android.com/reference/kotlin/androidx/wear/tiles/material/layouts/MultiButtonLayout#getButtonContents())(): (Mutable)List<LayoutElementBuilders.LayoutElement!>
```

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

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

> [!CAUTION]
> **This function 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/kotlin/androidx/wear/tiles/material/layouts/MultiButtonLayout#FIVE_BUTTON_DISTRIBUTION_BOTTOM_HEAVY()` will be returned.