# MultiSlotLayout

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

<br />

*** ** * ** ***

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

Opinionated Tiles layout, row like style with horizontally aligned and spaced slots (for icons or other small content). Should be used as a content passed in to the `https://developer.android.com/reference/kotlin/androidx/wear/tiles/material/layouts/PrimaryLayout`.

Recommended number of added slots is 1 to 3. Their width will be the width of an element passed in, with the `https://developer.android.com/reference/kotlin/androidx/wear/tiles/material/layouts/LayoutDefaults#MULTI_SLOT_LAYOUT_HORIZONTAL_SPACER_WIDTH()` space between.

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

MultiSlotLayout myMsl = (MultiSlotLayout) box.getContents().get(0);
```
will fail.

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

```kotlin
MultiSlotLayout myMsl = MultiSlotLayout.fromLayoutElement(box.getContents().get(0));
```

## Summary

| ### Nested types |
|---|
| `class https://developer.android.com/reference/kotlin/androidx/wear/tiles/material/layouts/MultiSlotLayout.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/layouts/MultiSlotLayout?` | `[fromLayoutElement](https://developer.android.com/reference/kotlin/androidx/wear/tiles/material/layouts/MultiSlotLayout#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/annotation/Dimension(unit = 0) https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` | `[getHorizontalSpacerWidth](https://developer.android.com/reference/kotlin/androidx/wear/tiles/material/layouts/MultiSlotLayout#getHorizontalSpacerWidth())()` **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!>` | `[getSlotContents](https://developer.android.com/reference/kotlin/androidx/wear/tiles/material/layouts/MultiSlotLayout#getSlotContents())()` **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/layouts/MultiSlotLayout#fromLayoutElement(androidx.wear.tiles.LayoutElementBuilders.LayoutElement))(element: LayoutElementBuilders.LayoutElement): MultiSlotLayout?
```

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

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

### getHorizontalSpacerWidth

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 [getHorizontalSpacerWidth](https://developer.android.com/reference/kotlin/androidx/wear/tiles/material/layouts/MultiSlotLayout#getHorizontalSpacerWidth())(): @Dimension(unit = 0) Float
```

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

Gets the width of horizontal spacer that is between slots.

### getSlotContents

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

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

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