---
title: "DpSize"
description: "A two-dimensional Size using [Dp] for units"
type: "class"
---

<div class='type'>Class</div>


<a id='references'></a>

<div class='sourceset sourceset-common'>Common</div>


```kotlin
value class DpSize internal constructor(@PublishedApi internal val packedValue: Long)
```


A two-dimensional Size using `Dp` for units


## Properties

<div class='sourceset sourceset-common'>Common</div>


```kotlin
val width: Dp
```


The horizontal aspect of the Size in `Dp`



<div class='sourceset sourceset-common'>Common</div>


```kotlin
val height: Dp
```


The vertical aspect of the Size in `Dp`



## Functions

```kotlin
fun copy(width: Dp = this.width, height: Dp = this.height): DpSize
```


Returns a copy of this `DpSize` instance optionally overriding the width or height parameter


```kotlin
operator fun minus(other: DpSize) =
        DpSize(packFloats((width - other.width).value, (height - other.height).value))
```


Subtract a `DpSize` from another one.


```kotlin
operator fun plus(other: DpSize) =
        DpSize(packFloats((width + other.width).value, (height + other.height).value))
```


Add a `DpSize` to another one.


```kotlin
inline operator fun component1(): Dp
```

```kotlin
inline operator fun component2(): Dp
```

```kotlin
operator fun times(other: Int): DpSize
```

```kotlin
operator fun times(other: Float): DpSize
```

```kotlin
operator fun div(other: Int): DpSize
```

```kotlin
operator fun div(other: Float): DpSize
```

## Companion Object

#### Properties

<div class='sourceset sourceset-common'>Common</div>


```kotlin
val Zero = DpSize(0x0L)
```


A `DpSize` with 0 DP `width` and 0 DP `height` values.



<div class='sourceset sourceset-common'>Common</div>


```kotlin
val Unspecified = DpSize(0x7fc00000_7fc00000L)
```


A size whose `width` and `height` are unspecified. This is usually a replacement for
`null` when a primitive value is desired. Access to `width` or `height` on an unspecified
size is not allowed.





