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

*** ** * ** ***


```
public final class EdgeContentLayout.Builder
```

<br />

*** ** * ** ***

Builder class for `https://developer.android.com/reference/androidx/wear/protolayout/material/layouts/EdgeContentLayout`.

## Summary

| ### Public constructors |
|---|
| `https://developer.android.com/reference/androidx/wear/protolayout/material/layouts/EdgeContentLayout.Builder#Builder(androidx.wear.protolayout.DeviceParametersBuilders.DeviceParameters)( @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/wear/protolayout/DeviceParametersBuilders.DeviceParameters deviceParameters )` Creates a builder for the `https://developer.android.com/reference/androidx/wear/protolayout/material/layouts/EdgeContentLayout`. |

| ### Public methods |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/wear/protolayout/material/layouts/EdgeContentLayout` | `https://developer.android.com/reference/androidx/wear/protolayout/material/layouts/EdgeContentLayout.Builder#build()()` Constructs and returns `https://developer.android.com/reference/androidx/wear/protolayout/material/layouts/EdgeContentLayout` with the provided content and look. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/wear/protolayout/material/layouts/EdgeContentLayout.Builder` | `https://developer.android.com/reference/androidx/wear/protolayout/material/layouts/EdgeContentLayout.Builder#setContent(androidx.wear.protolayout.LayoutElementBuilders.LayoutElement)(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/wear/protolayout/LayoutElementBuilders.LayoutElement content)` Sets the additional content to this layout, inside of the screen. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/wear/protolayout/material/layouts/EdgeContentLayout.Builder` | `https://developer.android.com/reference/androidx/wear/protolayout/material/layouts/EdgeContentLayout.Builder#setContentAndSecondaryLabelSpacing(androidx.wear.protolayout.DimensionBuilders.DpProp)( @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/wear/protolayout/DimensionBuilders.DpProp height )` Sets the space size between the additional content and secondary label if there is any. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/wear/protolayout/material/layouts/EdgeContentLayout.Builder` | `https://developer.android.com/reference/androidx/wear/protolayout/material/layouts/EdgeContentLayout.Builder#setEdgeContent(androidx.wear.protolayout.LayoutElementBuilders.LayoutElement)(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/wear/protolayout/LayoutElementBuilders.LayoutElement edgeContent)` Sets the content to be around the edges. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/wear/protolayout/material/layouts/EdgeContentLayout.Builder` | `https://developer.android.com/reference/androidx/wear/protolayout/material/layouts/EdgeContentLayout.Builder#setEdgeContentBehindAllOtherContent(boolean)(boolean isBehind)` Sets whether the edge content passed in with `https://developer.android.com/reference/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. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/wear/protolayout/material/layouts/EdgeContentLayout.Builder` | `https://developer.android.com/reference/androidx/wear/protolayout/material/layouts/EdgeContentLayout.Builder#setEdgeContentThickness(float)(@https://developer.android.com/reference/androidx/annotation/Dimension(unit = 0) float thickness)` Sets the thickness of the hollow edge content so that other content is correctly placed. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/wear/protolayout/material/layouts/EdgeContentLayout.Builder` | `https://developer.android.com/reference/androidx/wear/protolayout/material/layouts/EdgeContentLayout.Builder#setPrimaryLabelTextContent(androidx.wear.protolayout.LayoutElementBuilders.LayoutElement)( @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/wear/protolayout/LayoutElementBuilders.LayoutElement primaryLabelText )` Sets the content in the primary label slot. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/wear/protolayout/material/layouts/EdgeContentLayout.Builder` | `https://developer.android.com/reference/androidx/wear/protolayout/material/layouts/EdgeContentLayout.Builder#setResponsiveContentInsetEnabled(boolean)(boolean enabled)` Changes this `https://developer.android.com/reference/androidx/wear/protolayout/material/layouts/EdgeContentLayout` to better follow guidelines for type of layout that has content around the edge. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/wear/protolayout/material/layouts/EdgeContentLayout.Builder` | `https://developer.android.com/reference/androidx/wear/protolayout/material/layouts/EdgeContentLayout.Builder#setSecondaryLabelTextContent(androidx.wear.protolayout.LayoutElementBuilders.LayoutElement)( @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/wear/protolayout/LayoutElementBuilders.LayoutElement secondaryLabelText )` 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)

```
public Builder(
    @NonNull DeviceParametersBuilders.DeviceParameters deviceParameters
)
```

Creates a builder for the `https://developer.android.com/reference/androidx/wear/protolayout/material/layouts/EdgeContentLayout`. Custom content inside of it can later be set with (`https://developer.android.com/reference/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 `https://developer.android.com/reference/androidx/wear/protolayout/material/layouts/EdgeContentLayout.Builder#setResponsiveContentInsetEnabled(boolean)`.

## Public methods

### build

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

```
public @NonNull EdgeContentLayout build()
```

Constructs and returns `https://developer.android.com/reference/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)

```
public @NonNull EdgeContentLayout.Builder setContent(@NonNull LayoutElementBuilders.LayoutElement content)
```

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)

```
public @NonNull EdgeContentLayout.Builder setContentAndSecondaryLabelSpacing(
    @NonNull DimensionBuilders.DpProp height
)
```

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, `https://developer.android.com/reference/androidx/wear/protolayout/material/layouts/LayoutDefaults#DEFAULT_VERTICAL_SPACER_HEIGHT()` will be used.

Note that, this method should be used together with `https://developer.android.com/reference/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)

```
public @NonNull EdgeContentLayout.Builder setEdgeContent(@NonNull LayoutElementBuilders.LayoutElement edgeContent)
```

Sets the content to be around the edges. This can be `https://developer.android.com/reference/androidx/wear/protolayout/material/CircularProgressIndicator`.

If this content is something other that `https://developer.android.com/reference/androidx/wear/protolayout/material/CircularProgressIndicator`, please add its thickness with `https://developer.android.com/reference/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)

```
public @NonNull EdgeContentLayout.Builder setEdgeContentBehindAllOtherContent(boolean isBehind)
```

Sets whether the edge content passed in with `https://developer.android.com/reference/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 `https://developer.android.com/reference/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 |
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalStateException.html` | if this and `https://developer.android.com/reference/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)

```
public @NonNull EdgeContentLayout.Builder setEdgeContentThickness(@Dimension(unit = 0) float thickness)
```

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 `https://developer.android.com/reference/androidx/wear/protolayout/material/CircularProgressIndicator` or `https://developer.android.com/reference/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 `https://developer.android.com/reference/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)

```
public @NonNull EdgeContentLayout.Builder setPrimaryLabelTextContent(
    @NonNull LayoutElementBuilders.LayoutElement primaryLabelText
)
```

Sets the content in the primary label slot.

Depending on whether `https://developer.android.com/reference/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)

```
public @NonNull EdgeContentLayout.Builder setResponsiveContentInsetEnabled(boolean enabled)
```

Changes this `https://developer.android.com/reference/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 |
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalStateException.html` | if this and `https://developer.android.com/reference/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)

```
public @NonNull EdgeContentLayout.Builder setSecondaryLabelTextContent(
    @NonNull LayoutElementBuilders.LayoutElement secondaryLabelText
)
```

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 `https://developer.android.com/reference/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.