# DimensionBuilders

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

*** ** * ** ***


```
public final class DimensionBuilders
```

<br />

*** ** * ** ***

Builders for dimensions for layout elements.

## Summary

| ### Nested types |
|---|
| `@https://developer.android.com/reference/androidx/wear/protolayout/expression/RequiresSchemaVersion(major = 1, minor = 500) public interface https://developer.android.com/reference/androidx/wear/protolayout/DimensionBuilders.AngularDimension` Interface defining the length of an arc element. |
| `@https://developer.android.com/reference/androidx/wear/protolayout/expression/RequiresSchemaVersion(major = 1, minor = 200) public final class https://developer.android.com/reference/androidx/wear/protolayout/DimensionBuilders.AngularLayoutConstraint` A type for specifying layout constraints when using `https://developer.android.com/reference/androidx/wear/protolayout/DimensionBuilders.DegreesProp` on a data bindable layout element. |
| `public final class https://developer.android.com/reference/androidx/wear/protolayout/DimensionBuilders.AngularLayoutConstraint.Builder` Builder for `https://developer.android.com/reference/androidx/wear/protolayout/DimensionBuilders.AngularLayoutConstraint`. |
| `@https://developer.android.com/reference/androidx/wear/protolayout/expression/RequiresSchemaVersion(major = 1, minor = 400) public final class https://developer.android.com/reference/androidx/wear/protolayout/DimensionBuilders.BoundingBoxRatio implements https://developer.android.com/reference/androidx/wear/protolayout/DimensionBuilders.PivotDimension, https://developer.android.com/reference/androidx/wear/protolayout/DimensionBuilders.OffsetDimension` Provide a position representation proportional to the bounding box width/height. |
| `public final class https://developer.android.com/reference/androidx/wear/protolayout/DimensionBuilders.BoundingBoxRatio.Builder` Builder for `https://developer.android.com/reference/androidx/wear/protolayout/DimensionBuilders.BoundingBoxRatio`. |
| `@https://developer.android.com/reference/androidx/wear/protolayout/expression/RequiresSchemaVersion(major = 1, minor = 0) public interface https://developer.android.com/reference/androidx/wear/protolayout/DimensionBuilders.ContainerDimension` Interface defining a dimension that can be applied to a container. |
| `@https://developer.android.com/reference/androidx/wear/protolayout/expression/RequiresSchemaVersion(major = 1, minor = 0) public final class https://developer.android.com/reference/androidx/wear/protolayout/DimensionBuilders.DegreesProp implements https://developer.android.com/reference/androidx/wear/protolayout/DimensionBuilders.AngularDimension` A type for angular dimensions, measured in degrees. |
| `public final class https://developer.android.com/reference/androidx/wear/protolayout/DimensionBuilders.DegreesProp.Builder` Builder for `https://developer.android.com/reference/androidx/wear/protolayout/DimensionBuilders.DegreesProp` |
| `@https://developer.android.com/reference/androidx/wear/protolayout/expression/RequiresSchemaVersion(major = 1, minor = 0) public final class https://developer.android.com/reference/androidx/wear/protolayout/DimensionBuilders.DpProp implements https://developer.android.com/reference/androidx/wear/protolayout/DimensionBuilders.AngularDimension, https://developer.android.com/reference/androidx/wear/protolayout/DimensionBuilders.ContainerDimension, https://developer.android.com/reference/androidx/wear/protolayout/DimensionBuilders.ImageDimension, https://developer.android.com/reference/androidx/wear/protolayout/DimensionBuilders.SpacerDimension, https://developer.android.com/reference/androidx/wear/protolayout/DimensionBuilders.ExtensionDimension, https://developer.android.com/reference/androidx/wear/protolayout/DimensionBuilders.PivotDimension, https://developer.android.com/reference/androidx/wear/protolayout/DimensionBuilders.OffsetDimension` A type for linear dimensions, measured in dp. |
| `public final class https://developer.android.com/reference/androidx/wear/protolayout/DimensionBuilders.DpProp.Builder` Builder for `https://developer.android.com/reference/androidx/wear/protolayout/DimensionBuilders.DpProp`. |
| `@https://developer.android.com/reference/androidx/wear/protolayout/expression/RequiresSchemaVersion(major = 1, minor = 0) public final class https://developer.android.com/reference/androidx/wear/protolayout/DimensionBuilders.EmProp` A type for font spacing, measured in em. |
| `public final class https://developer.android.com/reference/androidx/wear/protolayout/DimensionBuilders.EmProp.Builder` Builder for `https://developer.android.com/reference/androidx/wear/protolayout/DimensionBuilders.EmProp` |
| `@https://developer.android.com/reference/androidx/wear/protolayout/expression/RequiresSchemaVersion(major = 1, minor = 0) public final class https://developer.android.com/reference/androidx/wear/protolayout/DimensionBuilders.ExpandedDimensionProp implements https://developer.android.com/reference/androidx/wear/protolayout/DimensionBuilders.ContainerDimension, https://developer.android.com/reference/androidx/wear/protolayout/DimensionBuilders.ImageDimension, https://developer.android.com/reference/androidx/wear/protolayout/DimensionBuilders.SpacerDimension` A type for a dimension that fills all the space it can (i.e. MATCH_PARENT in Android parlance). |
| `public final class https://developer.android.com/reference/androidx/wear/protolayout/DimensionBuilders.ExpandedDimensionProp.Builder` Builder for `https://developer.android.com/reference/androidx/wear/protolayout/DimensionBuilders.ExpandedDimensionProp`. |
| `@https://developer.android.com/reference/androidx/wear/protolayout/expression/RequiresSchemaVersion(major = 1, minor = 0) @https://developer.android.com/reference/androidx/wear/protolayout/expression/ExperimentalProtoLayoutExtensionApi public interface https://developer.android.com/reference/androidx/wear/protolayout/DimensionBuilders.ExtensionDimension` Interface defining a dimension that can be applied to a `https://developer.android.com/reference/androidx/wear/protolayout/LayoutElementBuilders.ExtensionLayoutElement` element. |
| `@https://developer.android.com/reference/androidx/wear/protolayout/expression/RequiresSchemaVersion(major = 1, minor = 200) public final class https://developer.android.com/reference/androidx/wear/protolayout/DimensionBuilders.HorizontalLayoutConstraint` A type for specifying horizontal layout constraints when using `https://developer.android.com/reference/androidx/wear/protolayout/DimensionBuilders.DpProp` on a data bindable layout element. |
| `public final class https://developer.android.com/reference/androidx/wear/protolayout/DimensionBuilders.HorizontalLayoutConstraint.Builder extends https://developer.android.com/reference/androidx/wear/protolayout/DimensionBuilders.DpPropLayoutConstraint.Builder` Builder for `https://developer.android.com/reference/androidx/wear/protolayout/DimensionBuilders.HorizontalLayoutConstraint`. |
| `@https://developer.android.com/reference/androidx/wear/protolayout/expression/RequiresSchemaVersion(major = 1, minor = 0) public interface https://developer.android.com/reference/androidx/wear/protolayout/DimensionBuilders.ImageDimension` Interface defining a dimension that can be applied to an image. |
| `@https://developer.android.com/reference/androidx/wear/protolayout/expression/RequiresSchemaVersion(major = 1, minor = 500) public interface https://developer.android.com/reference/androidx/wear/protolayout/DimensionBuilders.OffsetDimension` Interface defining a dimension that represents an offset relative to the element's position. |
| `@https://developer.android.com/reference/androidx/wear/protolayout/expression/RequiresSchemaVersion(major = 1, minor = 400) public interface https://developer.android.com/reference/androidx/wear/protolayout/DimensionBuilders.PivotDimension` Interface defining a dimension that can be applied to a pivot location for scale and rotate transformations. |
| `@https://developer.android.com/reference/androidx/wear/protolayout/expression/RequiresSchemaVersion(major = 1, minor = 0) public final class https://developer.android.com/reference/androidx/wear/protolayout/DimensionBuilders.ProportionalDimensionProp implements https://developer.android.com/reference/androidx/wear/protolayout/DimensionBuilders.ImageDimension` A type for a dimension that scales itself proportionally to another dimension such that the aspect ratio defined by the given width and height values is preserved. |
| `public final class https://developer.android.com/reference/androidx/wear/protolayout/DimensionBuilders.ProportionalDimensionProp.Builder` Builder for `https://developer.android.com/reference/androidx/wear/protolayout/DimensionBuilders.ProportionalDimensionProp`. |
| `@https://developer.android.com/reference/androidx/wear/protolayout/expression/RequiresSchemaVersion(major = 1, minor = 0) public final class https://developer.android.com/reference/androidx/wear/protolayout/DimensionBuilders.SpProp` A type for font sizes, measured in sp. |
| `public final class https://developer.android.com/reference/androidx/wear/protolayout/DimensionBuilders.SpProp.Builder` Builder for `https://developer.android.com/reference/androidx/wear/protolayout/DimensionBuilders.SpProp` |
| `@https://developer.android.com/reference/androidx/wear/protolayout/expression/RequiresSchemaVersion(major = 1, minor = 0) public interface https://developer.android.com/reference/androidx/wear/protolayout/DimensionBuilders.SpacerDimension` Interface defining a dimension that can be applied to a spacer. |
| `@https://developer.android.com/reference/androidx/wear/protolayout/expression/RequiresSchemaVersion(major = 1, minor = 200) public final class https://developer.android.com/reference/androidx/wear/protolayout/DimensionBuilders.VerticalLayoutConstraint` A type for specifying vertical layout constraints when using `https://developer.android.com/reference/androidx/wear/protolayout/DimensionBuilders.DpProp` on a data bindable layout element. |
| `public final class https://developer.android.com/reference/androidx/wear/protolayout/DimensionBuilders.VerticalLayoutConstraint.Builder extends https://developer.android.com/reference/androidx/wear/protolayout/DimensionBuilders.DpPropLayoutConstraint.Builder` Builder for `https://developer.android.com/reference/androidx/wear/protolayout/DimensionBuilders.VerticalLayoutConstraint`. |
| `@https://developer.android.com/reference/androidx/wear/protolayout/expression/RequiresSchemaVersion(major = 1, minor = 0) public final class https://developer.android.com/reference/androidx/wear/protolayout/DimensionBuilders.WrappedDimensionProp implements https://developer.android.com/reference/androidx/wear/protolayout/DimensionBuilders.ContainerDimension` A type for a dimension that sizes itself to the size of its children (i.e. WRAP_CONTENT in Android parlance). |
| `public final class https://developer.android.com/reference/androidx/wear/protolayout/DimensionBuilders.WrappedDimensionProp.Builder` Builder for `https://developer.android.com/reference/androidx/wear/protolayout/DimensionBuilders.WrappedDimensionProp`. |

| ### Public methods |
|---|---|
| `static @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/wear/protolayout/DimensionBuilders.DegreesProp` | `@https://developer.android.com/reference/androidx/wear/protolayout/expression/RequiresSchemaVersion(major = 1, minor = 0) https://developer.android.com/reference/androidx/wear/protolayout/DimensionBuilders#degrees(float)(float valueDegrees)` Shortcut for building an `https://developer.android.com/reference/androidx/wear/protolayout/DimensionBuilders.DegreesProp` using a measurement in degrees. |
| `static @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/wear/protolayout/DimensionBuilders.DpProp` | `@https://developer.android.com/reference/androidx/wear/protolayout/expression/RequiresSchemaVersion(major = 1, minor = 0) https://developer.android.com/reference/androidx/wear/protolayout/DimensionBuilders#dp(float)(@https://developer.android.com/reference/androidx/annotation/Dimension(unit = 0) float valueDp)` Shortcut for building a `https://developer.android.com/reference/androidx/wear/protolayout/DimensionBuilders.DpProp` using a measurement in DP. |
| `static @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/wear/protolayout/DimensionBuilders.EmProp` | `@https://developer.android.com/reference/androidx/wear/protolayout/expression/RequiresSchemaVersion(major = 1, minor = 0) https://developer.android.com/reference/androidx/wear/protolayout/DimensionBuilders#em(float)(float valueEm)` Shortcut for building a `https://developer.android.com/reference/androidx/wear/protolayout/DimensionBuilders.EmProp` using a measurement in EM. |
| `static @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/wear/protolayout/DimensionBuilders.EmProp` | `@https://developer.android.com/reference/androidx/wear/protolayout/expression/RequiresSchemaVersion(major = 1, minor = 0) https://developer.android.com/reference/androidx/wear/protolayout/DimensionBuilders#em(int)(int valueEm)` Shortcut for building a `https://developer.android.com/reference/androidx/wear/protolayout/DimensionBuilders.EmProp` using a measurement in EM. |
| `static @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/wear/protolayout/DimensionBuilders.ExpandedDimensionProp` | `@https://developer.android.com/reference/androidx/wear/protolayout/expression/RequiresSchemaVersion(major = 1, minor = 0) https://developer.android.com/reference/androidx/wear/protolayout/DimensionBuilders#expand()()` Shortcut for building an `https://developer.android.com/reference/androidx/wear/protolayout/DimensionBuilders.ExpandedDimensionProp` that will expand to the size of its parent. |
| `static @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/wear/protolayout/DimensionBuilders.SpProp` | `@https://developer.android.com/reference/androidx/wear/protolayout/expression/RequiresSchemaVersion(major = 1, minor = 0) https://developer.android.com/reference/androidx/wear/protolayout/DimensionBuilders#sp(float)(@https://developer.android.com/reference/androidx/annotation/Dimension(unit = 2) float valueSp)` Shortcut for building a `https://developer.android.com/reference/androidx/wear/protolayout/DimensionBuilders.SpProp` using a measurement in SP. |
| `static @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/wear/protolayout/DimensionBuilders.ExpandedDimensionProp` | `@https://developer.android.com/reference/androidx/wear/protolayout/expression/RequiresSchemaVersion(major = 1, minor = 300) https://developer.android.com/reference/androidx/wear/protolayout/DimensionBuilders#weight(float)(@https://developer.android.com/reference/androidx/annotation/FloatRange(from = 0.0) float weight)` Shortcut for building an `https://developer.android.com/reference/androidx/wear/protolayout/DimensionBuilders.ExpandedDimensionProp` with weight (a dimensionless scalar value). |
| `static @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/wear/protolayout/DimensionBuilders.WrappedDimensionProp` | `@https://developer.android.com/reference/androidx/wear/protolayout/expression/RequiresSchemaVersion(major = 1, minor = 0) https://developer.android.com/reference/androidx/wear/protolayout/DimensionBuilders#wrap()()` Shortcut for building an `https://developer.android.com/reference/androidx/wear/protolayout/DimensionBuilders.WrappedDimensionProp` that will shrink to the size of its children. |

## Public methods

### degrees

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

```
@RequiresSchemaVersion(major = 1, minor = 0)
public static @NonNull DimensionBuilders.DegreesProp degrees(float valueDegrees)
```

Shortcut for building an `https://developer.android.com/reference/androidx/wear/protolayout/DimensionBuilders.DegreesProp` using a measurement in degrees.

### dp

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

```
@RequiresSchemaVersion(major = 1, minor = 0)
public static @NonNull DimensionBuilders.DpProp dp(@Dimension(unit = 0) float valueDp)
```

Shortcut for building a `https://developer.android.com/reference/androidx/wear/protolayout/DimensionBuilders.DpProp` using a measurement in DP.

### em

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

```
@RequiresSchemaVersion(major = 1, minor = 0)
public static @NonNull DimensionBuilders.EmProp em(float valueEm)
```

Shortcut for building a `https://developer.android.com/reference/androidx/wear/protolayout/DimensionBuilders.EmProp` using a measurement in EM.

### em

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

```
@RequiresSchemaVersion(major = 1, minor = 0)
public static @NonNull DimensionBuilders.EmProp em(int valueEm)
```

Shortcut for building a `https://developer.android.com/reference/androidx/wear/protolayout/DimensionBuilders.EmProp` using a measurement in EM.

### expand

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

```
@RequiresSchemaVersion(major = 1, minor = 0)
public static @NonNull DimensionBuilders.ExpandedDimensionProp expand()
```

Shortcut for building an `https://developer.android.com/reference/androidx/wear/protolayout/DimensionBuilders.ExpandedDimensionProp` that will expand to the size of its parent.

### sp

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

```
@RequiresSchemaVersion(major = 1, minor = 0)
public static @NonNull DimensionBuilders.SpProp sp(@Dimension(unit = 2) float valueSp)
```

Shortcut for building a `https://developer.android.com/reference/androidx/wear/protolayout/DimensionBuilders.SpProp` using a measurement in SP.

### weight

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

```
@RequiresSchemaVersion(major = 1, minor = 300)
public static @NonNull DimensionBuilders.ExpandedDimensionProp weight(@FloatRange(from = 0.0) float weight)
```

Shortcut for building an `https://developer.android.com/reference/androidx/wear/protolayout/DimensionBuilders.ExpandedDimensionProp` with weight (a dimensionless scalar value).

This will only affect the width of children of a `https://developer.android.com/reference/androidx/wear/protolayout/LayoutElementBuilders.Row` or the height of children of a `https://developer.android.com/reference/androidx/wear/protolayout/LayoutElementBuilders.Column`, otherwise it will expand to the size of its parent. Where applicable, the remaining space in the width or height left from the children with fixed or wrapped dimension will be proportionally split across children with expand dimension, meaning that the width or height of the element is proportional to the sum of the weights of its weighted siblings. For the siblings that don't have weight set, but they are expanded, defaults to 1.

### wrap

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

```
@RequiresSchemaVersion(major = 1, minor = 0)
public static @NonNull DimensionBuilders.WrappedDimensionProp wrap()
```

Shortcut for building an `https://developer.android.com/reference/androidx/wear/protolayout/DimensionBuilders.WrappedDimensionProp` that will shrink to the size of its children.