# EdgeContentLayout.Builder

# EdgeContentLayout.Builder

Artifact:[androidx.wear.protolayout:protolayout-material](https://developer.android.com/jetpack/androidx/releases/wear-protolayout)  
[View Source](https://cs.android.com/search?q=file:androidx/wear/protolayout/material/layouts/EdgeContentLayout.java+class:androidx.wear.protolayout.material.layouts.EdgeContentLayout.Builder)  
Added in[1.0.0](https://developer.android.com/jetpack/androidx/releases/wear-protolayout#1.0.0)

*** ** * ** ***

Kotlin\|[Java](https://developer.android.com/reference/androidx/wear/protolayout/material/layouts/EdgeContentLayout.Builder "View this page in Java")

<br />

```
class EdgeContentLayout.Builder
```

<br />

*** ** * ** ***

Builder class for[EdgeContentLayout](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/material/layouts/EdgeContentLayout).

## Summary

|                                                                                                                                                                                                                                                                    ### Public constructors                                                                                                                                                                                                                                                                    |
|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [Builder](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/material/layouts/EdgeContentLayout.Builder#Builder(androidx.wear.protolayout.DeviceParametersBuilders.DeviceParameters))`(deviceParameters: `[DeviceParametersBuilders.DeviceParameters](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/DeviceParametersBuilders.DeviceParameters)`)` Creates a builder for the[EdgeContentLayout](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/material/layouts/EdgeContentLayout). |

|                                                               ### Public functions                                                               |
|--------------------------------------------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [EdgeContentLayout](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/material/layouts/EdgeContentLayout)                 | [build](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/material/layouts/EdgeContentLayout.Builder#build())`()` Constructs and returns[EdgeContentLayout](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/material/layouts/EdgeContentLayout)with the provided content and look.                                                                                                                                                                                                                                                                                                                  |
| [EdgeContentLayout.Builder](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/material/layouts/EdgeContentLayout.Builder) | [setContent](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/material/layouts/EdgeContentLayout.Builder#setContent(androidx.wear.protolayout.LayoutElementBuilders.LayoutElement))`(content: `[LayoutElementBuilders.LayoutElement](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/LayoutElementBuilders.LayoutElement)`)` Sets the additional content to this layout, inside of the screen.                                                                                                                                                                                                     |
| [EdgeContentLayout.Builder](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/material/layouts/EdgeContentLayout.Builder) | [setContentAndSecondaryLabelSpacing](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/material/layouts/EdgeContentLayout.Builder#setContentAndSecondaryLabelSpacing(androidx.wear.protolayout.DimensionBuilders.DpProp))`(height: `[DimensionBuilders.DpProp](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/DimensionBuilders.DpProp)`)` Sets the space size between the additional content and secondary label if there is any.                                                                                                                                                                 |
| [EdgeContentLayout.Builder](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/material/layouts/EdgeContentLayout.Builder) | [setEdgeContent](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/material/layouts/EdgeContentLayout.Builder#setEdgeContent(androidx.wear.protolayout.LayoutElementBuilders.LayoutElement))`(edgeContent: `[LayoutElementBuilders.LayoutElement](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/LayoutElementBuilders.LayoutElement)`)` Sets the content to be around the edges.                                                                                                                                                                                                                  |
| [EdgeContentLayout.Builder](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/material/layouts/EdgeContentLayout.Builder) | [setEdgeContentBehindAllOtherContent](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/material/layouts/EdgeContentLayout.Builder#setEdgeContentBehindAllOtherContent(boolean))`(isBehind: `[Boolean](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html)`)` Sets whether the edge content passed in with[setEdgeContent](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/material/layouts/EdgeContentLayout.Builder#setEdgeContent(androidx.wear.protolayout.LayoutElementBuilders.LayoutElement))should be positioned behind all other content in this layout or above it. |
| [EdgeContentLayout.Builder](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/material/layouts/EdgeContentLayout.Builder) | [setEdgeContentThickness](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/material/layouts/EdgeContentLayout.Builder#setEdgeContentThickness(float))`(thickness: @`[Dimension](https://developer.android.com/reference/kotlin/androidx/annotation/Dimension)`(unit = 0) `[Float](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html)`)` Sets the thickness of the hollow edge content so that other content is correctly placed.                                                                                                                                                                       |
| [EdgeContentLayout.Builder](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/material/layouts/EdgeContentLayout.Builder) | [setPrimaryLabelTextContent](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/material/layouts/EdgeContentLayout.Builder#setPrimaryLabelTextContent(androidx.wear.protolayout.LayoutElementBuilders.LayoutElement))`(` ` primaryLabelText: `[LayoutElementBuilders.LayoutElement](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/LayoutElementBuilders.LayoutElement) `)` Sets the content in the primary label slot.                                                                                                                                                                             |
| [EdgeContentLayout.Builder](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/material/layouts/EdgeContentLayout.Builder) | [setResponsiveContentInsetEnabled](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/material/layouts/EdgeContentLayout.Builder#setResponsiveContentInsetEnabled(boolean))`(enabled: `[Boolean](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html)`)` Changes this[EdgeContentLayout](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/material/layouts/EdgeContentLayout)to better follow guidelines for type of layout that has content around the edge.                                                                                                                    |
| [EdgeContentLayout.Builder](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/material/layouts/EdgeContentLayout.Builder) | [setSecondaryLabelTextContent](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/material/layouts/EdgeContentLayout.Builder#setSecondaryLabelTextContent(androidx.wear.protolayout.LayoutElementBuilders.LayoutElement))`(` ` secondaryLabelText: `[LayoutElementBuilders.LayoutElement](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/LayoutElementBuilders.LayoutElement) `)` Sets the content in the secondary label slot which will be below the additional content.                                                                                                                          |

## Public constructors

### Builder

Added in[1.0.0](https://developer.android.com/jetpack/androidx/releases/wear-protolayout#1.0.0)  

```
Builder(deviceParameters: DeviceParametersBuilders.DeviceParameters)
```

Creates a builder for the[EdgeContentLayout](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/material/layouts/EdgeContentLayout). Custom content inside of it can later be set with ([setContent](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/material/layouts/EdgeContentLayout.Builder#setContent(androidx.wear.protolayout.LayoutElementBuilders.LayoutElement)).

For optimal layouts across different screen sizes and better alignment with UX guidelines, it is highly recommended to call[setResponsiveContentInsetEnabled](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/material/layouts/EdgeContentLayout.Builder#setResponsiveContentInsetEnabled(boolean)).  

## Public functions

### build

Added in[1.0.0](https://developer.android.com/jetpack/androidx/releases/wear-protolayout#1.0.0)  

```
fun build(): EdgeContentLayout
```

Constructs and returns[EdgeContentLayout](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/material/layouts/EdgeContentLayout)with the provided content and look.  

### setContent

Added in[1.0.0](https://developer.android.com/jetpack/androidx/releases/wear-protolayout#1.0.0)  

```
fun setContent(content: LayoutElementBuilders.LayoutElement): EdgeContentLayout.Builder
```

Sets the additional content to this layout, inside of the screen.  

### setContentAndSecondaryLabelSpacing

Added in[1.2.0](https://developer.android.com/jetpack/androidx/releases/wear-protolayout#1.2.0)  

```
fun setContentAndSecondaryLabelSpacing(height: DimensionBuilders.DpProp): EdgeContentLayout.Builder
```

Sets the space size between the additional content and secondary label if there is any. If one of those is not present, spacer is not used. If not set,[DEFAULT_VERTICAL_SPACER_HEIGHT](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/material/layouts/LayoutDefaults#DEFAULT_VERTICAL_SPACER_HEIGHT())will be used.

Note that, this method should be used together with[setResponsiveContentInsetEnabled](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/material/layouts/EdgeContentLayout.Builder#setResponsiveContentInsetEnabled(boolean)), otherwise it will be ignored.  

### setEdgeContent

Added in[1.0.0](https://developer.android.com/jetpack/androidx/releases/wear-protolayout#1.0.0)  

```
fun setEdgeContent(edgeContent: LayoutElementBuilders.LayoutElement): EdgeContentLayout.Builder
```

Sets the content to be around the edges. This can be[CircularProgressIndicator](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/material/CircularProgressIndicator).

If this content is something other that[CircularProgressIndicator](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/material/CircularProgressIndicator), please add its thickness with[setEdgeContentThickness](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/material/layouts/EdgeContentLayout.Builder#setEdgeContentThickness(float))for best results.  

### setEdgeContentBehindAllOtherContent

Added in[1.1.0](https://developer.android.com/jetpack/androidx/releases/wear-protolayout#1.1.0)  

```
fun setEdgeContentBehindAllOtherContent(isBehind: Boolean): EdgeContentLayout.Builder
```

Sets whether the edge content passed in with[setEdgeContent](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/material/layouts/EdgeContentLayout.Builder#setEdgeContent(androidx.wear.protolayout.LayoutElementBuilders.LayoutElement))should be positioned behind all other content in this layout or above it. If not set, defaults to`
false`, meaning that the edge content will be placed above all other content.

Note that, if[setResponsiveContentInsetEnabled](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/material/layouts/EdgeContentLayout.Builder#setResponsiveContentInsetEnabled(boolean))is set to`true`, edge content will always go behind all other content and this method call will throw as those shouldn't be mixed.  

|                                                     Throws                                                      |
|-----------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [java.lang.IllegalStateException](https://developer.android.com/reference/java/lang/IllegalStateException.html) | if this and[setResponsiveContentInsetEnabled](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/material/layouts/EdgeContentLayout.Builder#setResponsiveContentInsetEnabled(boolean))are used together. |

### setEdgeContentThickness

Added in[1.2.0](https://developer.android.com/jetpack/androidx/releases/wear-protolayout#1.2.0)  

```
fun setEdgeContentThickness(thickness: @Dimension(unit = 0) Float): EdgeContentLayout.Builder
```

Sets the thickness of the hollow edge content so that other content is correctly placed. In other words, sets the space that should be reserved exclusively for the edge content and not be overdrawn by other inner content.

For example, for[CircularProgressIndicator](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/material/CircularProgressIndicator)or[androidx.wear.protolayout.LayoutElementBuilders.ArcLine](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/LayoutElementBuilders.ArcLine)elements, this should be equal to their stroke width/thickness.

Note that, calling this method when responsiveness is not set with[setResponsiveContentInsetEnabled](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/material/layouts/EdgeContentLayout.Builder#setResponsiveContentInsetEnabled(boolean)), will be ignored.  

### setPrimaryLabelTextContent

Added in[1.0.0](https://developer.android.com/jetpack/androidx/releases/wear-protolayout#1.0.0)  

```
fun setPrimaryLabelTextContent(
    primaryLabelText: LayoutElementBuilders.LayoutElement
): EdgeContentLayout.Builder
```

Sets the content in the primary label slot.

Depending on whether[setResponsiveContentInsetEnabled](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/material/layouts/EdgeContentLayout.Builder#setResponsiveContentInsetEnabled(boolean))is set to true or not, this label will be placed as following: - If responsive behaviour is set, label will be above the additional content, on a fixed place to ensure Tiles consistency with other layouts. Additionally, the label will also have an inset to prevent it from going off the screen. - If responsive behaviour is not set or called, label will be above the additional content, centered in the remaining space.  

### setResponsiveContentInsetEnabled

Added in[1.2.0](https://developer.android.com/jetpack/androidx/releases/wear-protolayout#1.2.0)  

```
fun setResponsiveContentInsetEnabled(enabled: Boolean): EdgeContentLayout.Builder
```

Changes this[EdgeContentLayout](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/material/layouts/EdgeContentLayout)to better follow guidelines for type of layout that has content around the edge.

These updates include: 1. Using responsive insets for its content primary and secondary label by adding some additional space on the sides of these elements to avoid content going off the screen edge. 2. Changing layout padding to responsive to better follow different screen sizes. 3. Positioning primary label at a fixed place on top of the screen rather than following additional content.

It is highly recommended to call this method with`true`when using this layout to optimize it for different screen sizes.  

|                                                     Throws                                                      |
|-----------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [java.lang.IllegalStateException](https://developer.android.com/reference/java/lang/IllegalStateException.html) | if this and[setEdgeContentBehindAllOtherContent](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/material/layouts/EdgeContentLayout.Builder#setEdgeContentBehindAllOtherContent(boolean))are used together. |

### setSecondaryLabelTextContent

Added in[1.0.0](https://developer.android.com/jetpack/androidx/releases/wear-protolayout#1.0.0)  

```
fun setSecondaryLabelTextContent(
    secondaryLabelText: LayoutElementBuilders.LayoutElement
): EdgeContentLayout.Builder
```

Sets the content in the secondary label slot which will be below the additional content. It is highly recommended to have primary label set when having secondary label.

Note that when[setResponsiveContentInsetEnabled](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/material/layouts/EdgeContentLayout.Builder#setResponsiveContentInsetEnabled(boolean))is set to`true`, the label will also have an inset to prevent it from going off the screen.