---
title: "Density"
description: "A density of the screen. Used for convert [Dp] to pixels."
type: "function"
---

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


<a id='references'></a>
<div class='sourceset sourceset-common'>Common</div>


```kotlin
fun Density(density: Float, fontScale: Float = 1f): Density
```


A density of the screen. Used for convert `Dp` to pixels.

#### Parameters

| | |
| --- | --- |
| density | The logical density of the display. This is a scaling factor for the `Dp` unit. |
| fontScale | Current user preference for the scaling factor for fonts. |




<div class='sourceset sourceset-android'>Android</div>


```kotlin
fun Density(context: Context): Density
```


Creates a `Density` for this `Context`.

#### Parameters

| | |
| --- | --- |
| context | density values will be extracted from this `Context` |




