# Size

Artifact: [androidx.media3:media3-common](https://developer.android.com/jetpack/androidx/releases/media3) [View Source](https://cs.android.com/search?q=file:androidx/media3/common/util/Size.java+class:androidx.media3.common.util.Size)

*** ** * ** ***


```
@UnstableApi
public final class Size
```

<br />

*** ** * ** ***

Immutable class for describing width and height dimensions in pixels.

## Summary

| ### Constants |
|---|---|
| `static final https://developer.android.com/reference/androidx/media3/common/util/Size` | `https://developer.android.com/reference/androidx/media3/common/util/Size#UNKNOWN()` A static instance to represent an unknown size value. |
| `static final https://developer.android.com/reference/androidx/media3/common/util/Size` | `https://developer.android.com/reference/androidx/media3/common/util/Size#ZERO()` |

| ### Public fields |
|---|---|
| `final int` | `https://developer.android.com/reference/androidx/media3/common/util/Size#height()` |
| `final int` | `https://developer.android.com/reference/androidx/media3/common/util/Size#width()` |

| ### Public constructors |
|---|
| `https://developer.android.com/reference/androidx/media3/common/util/Size#Size(int,int)(int width, int height)` Creates a new immutable Size instance. |

| ### Public methods |
|---|---|
| `boolean` | `https://developer.android.com/reference/androidx/media3/common/util/Size#equals(java.lang.Object)(@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/java/lang/Object.html obj)` |
| `static https://developer.android.com/reference/androidx/media3/common/util/Size` | `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi https://developer.android.com/reference/androidx/media3/common/util/Size#fromBundle(android.os.Bundle)(https://developer.android.com/reference/android/os/Bundle.html bundle)` |
| `int` | `https://developer.android.com/reference/androidx/media3/common/util/Size#getHeight()()` Returns the height of the size (in pixels), or `https://developer.android.com/reference/androidx/media3/common/C#LENGTH_UNSET()` if unknown. |
| `int` | `https://developer.android.com/reference/androidx/media3/common/util/Size#getWidth()()` Returns the width of the size (in pixels), or `https://developer.android.com/reference/androidx/media3/common/C#LENGTH_UNSET()` if unknown. |
| `int` | `https://developer.android.com/reference/androidx/media3/common/util/Size#hashCode()()` |
| `https://developer.android.com/reference/android/os/Bundle.html` | `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi https://developer.android.com/reference/androidx/media3/common/util/Size#toBundle()()` |
| `https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/androidx/media3/common/util/Size#toString()()` |

## Constants

### UNKNOWN

```
public static final Size UNKNOWN
```

A static instance to represent an unknown size value.

### ZERO

```
public static final Size ZERO
```

## Public fields

### height

```
public final int height
```

### width

```
public final int width
```

## Public constructors

### Size

```
public Size(int width, int height)
```

Creates a new immutable Size instance.

| Parameters |
|---|---|
| `int width` | The width of the size, in pixels, or `https://developer.android.com/reference/androidx/media3/common/C#LENGTH_UNSET()` if unknown. |
| `int height` | The height of the size, in pixels, or `https://developer.android.com/reference/androidx/media3/common/C#LENGTH_UNSET()` if unknown. |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalArgumentException.html` | if an invalid `width` or `height` is specified. |

## Public methods

### equals

```
public boolean equals(@Nullable Object obj)
```

### fromBundle

```
@UnstableApi
public static Size fromBundle(Bundle bundle)
```

### getHeight

```
public int getHeight()
```

Returns the height of the size (in pixels), or `https://developer.android.com/reference/androidx/media3/common/C#LENGTH_UNSET()` if unknown.

### getWidth

```
public int getWidth()
```

Returns the width of the size (in pixels), or `https://developer.android.com/reference/androidx/media3/common/C#LENGTH_UNSET()` if unknown.

### hashCode

```
public int hashCode()
```

### toBundle

```
@UnstableApi
public Bundle toBundle()
```

### toString

```
public String toString()
```