# asPaddingValues

Common/AllAndroid/JVM

## Functions summary

|---|---|---|
| `https://developer.android.com/reference/kotlin/androidx/compose/foundation/layout/PaddingValues` | `@https://developer.android.com/reference/kotlin/androidx/compose/runtime/Composable https://developer.android.com/reference/kotlin/androidx/compose/foundation/layout/WindowInsets.https://developer.android.com/reference/kotlin/androidx/compose/foundation/layout/asPaddingValues.composable#(androidx.compose.foundation.layout.WindowInsets).asPaddingValues()()` Convert a `https://developer.android.com/reference/kotlin/androidx/compose/foundation/layout/WindowInsets` to a `https://developer.android.com/reference/kotlin/androidx/compose/foundation/layout/PaddingValues` and uses `https://developer.android.com/reference/kotlin/androidx/compose/ui/platform/package-summary#LocalDensity()` for DP to pixel conversion. | Cmn |

## Functions

### WindowInsets.asPaddingValues

Cmn Artifact: [androidx.compose.foundation:foundation-layout](https://developer.android.com/jetpack/androidx/releases/compose-foundation) [View Source](https://cs.android.com/search?q=file:androidx/compose/foundation/layout/WindowInsets.kt+function:asPaddingValues) Added in [1.2.0](https://developer.android.com/jetpack/androidx/releases/compose-foundation#1.2.0)

```
@Composable
fun WindowInsets.asPaddingValues(): PaddingValues
```

Convert a `https://developer.android.com/reference/kotlin/androidx/compose/foundation/layout/WindowInsets` to a `https://developer.android.com/reference/kotlin/androidx/compose/foundation/layout/PaddingValues` and uses `https://developer.android.com/reference/kotlin/androidx/compose/ui/platform/package-summary#LocalDensity()` for DP to pixel conversion. `https://developer.android.com/reference/kotlin/androidx/compose/foundation/layout/PaddingValues` can be passed to some containers to pad internal content so that it doesn't overlap the insets when fully scrolled. Ensure that the insets are `https://developer.android.com/reference/kotlin/androidx/compose/foundation/layout/consumeWindowInsets.modifier#(androidx.compose.ui.Modifier).consumeWindowInsets(androidx.compose.foundation.layout.WindowInsets)` after the padding is applied if insets are to be used further down the hierarchy.

```kotlin
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.WindowInsets
import androidx.compose.foundation.layout.asPaddingValues
import androidx.compose.foundation.layout.navigationBars
import androidx.compose.foundation.lazy.LazyColumn
import androidx.core.view.WindowCompat

class SampleActivity : ComponentActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        WindowCompat.setDecorFitsSystemWindows(window, false)
        super.onCreate(savedInstanceState)
        setContent {
            LazyColumn(contentPadding = WindowInsets.navigationBars.asPaddingValues()) {
                // items
            }
        }
    }
}
```