---
title: "addView"
type: "function"
lastmod: "2026-08-27"
---
## API Reference

### addView

> Source set: Android

```kotlin
override fun addView(child: View?) = addView(child, -1)
```

### addView

> Source set: Android

```kotlin
override fun addView(child: View?, index: Int) =
        addView(child, index, child!!.layoutParams ?: generateDefaultLayoutParams())
```

### addView

> Source set: Android

```kotlin
override fun addView(child: View?, width: Int, height: Int) =
        addView(
            child,
            -1,
            generateDefaultLayoutParams().also {
                it.width = width
                it.height = height
            },
        )
```

### addView

> Source set: Android

```kotlin
override fun addView(child: View?, params: LayoutParams?) = addView(child, -1, params)
```

### addView

> Source set: Android

```kotlin
override fun addView(child: View?, index: Int, params: LayoutParams?)
```

Directly adding _real_ `View`s to this view is not supported for external consumers, so we
can use the non-layout-invalidating `addViewInLayout` for when we need to add utility
container views, such as `viewLayersContainer`.
