# PrimaryLayout

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

<br />

*** ** * ** ***

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

Tiles layout that represents a suggested layout style for Material Tiles with the primary (compact) chip at the bottom with the given content in the center and the recommended margin and padding applied. There is a fixed slot for an optional primary label above or optional secondary label below the main content area.

It is highly recommended that main content has max lines between 2 and 4 (dependant on labels present), i.e.: \* No labels are present: content with max 4 lines, \* 1 label is present: content with max 3 lines, \* 2 labels are present: content with max 2 lines.

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

PrimaryLayout myPl = (PrimaryLayout) box.getContents().get(0);
```
will fail.

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

```kotlin
PrimaryLayout myPl = PrimaryLayout.fromLayoutElement(box.getContents().get(0));
```

## Summary

| ### Nested types |
|---|
| `class https://developer.android.com/reference/kotlin/androidx/wear/tiles/material/layouts/PrimaryLayout.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/PrimaryLayout?` | `[fromLayoutElement](https://developer.android.com/reference/kotlin/androidx/wear/tiles/material/layouts/PrimaryLayout#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/LayoutElementBuilders.LayoutElement?` | `[getContent](https://developer.android.com/reference/kotlin/androidx/wear/tiles/material/layouts/PrimaryLayout#getContent())()` **This function is deprecated.** Deprecated in Java |
| `https://developer.android.com/reference/kotlin/androidx/wear/tiles/LayoutElementBuilders.LayoutElement?` | `[getPrimaryChipContent](https://developer.android.com/reference/kotlin/androidx/wear/tiles/material/layouts/PrimaryLayout#getPrimaryChipContent())()` **This function is deprecated.** Deprecated in Java |
| `https://developer.android.com/reference/kotlin/androidx/wear/tiles/LayoutElementBuilders.LayoutElement?` | `[getPrimaryLabelTextContent](https://developer.android.com/reference/kotlin/androidx/wear/tiles/material/layouts/PrimaryLayout#getPrimaryLabelTextContent())()` **This function is deprecated.** Deprecated in Java |
| `https://developer.android.com/reference/kotlin/androidx/wear/tiles/LayoutElementBuilders.LayoutElement?` | `[getSecondaryLabelTextContent](https://developer.android.com/reference/kotlin/androidx/wear/tiles/material/layouts/PrimaryLayout#getSecondaryLabelTextContent())()` **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` | `[getVerticalSpacerHeight](https://developer.android.com/reference/kotlin/androidx/wear/tiles/material/layouts/PrimaryLayout#getVerticalSpacerHeight())()` **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/PrimaryLayout#fromLayoutElement(androidx.wear.tiles.LayoutElementBuilders.LayoutElement))(element: LayoutElementBuilders.LayoutElement): PrimaryLayout?
```

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

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

### getContent

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

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

Get the inner content from this layout.

### getPrimaryChipContent

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

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

Get the primary chip content from this layout.

### getPrimaryLabelTextContent

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

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

Get the primary label content from this layout.

### getSecondaryLabelTextContent

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

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

Get the secondary label content from this layout.

### getVerticalSpacerHeight

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

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

Get the vertical spacer height from this layout.