# LayoutInflaterCompat

# LayoutInflaterCompat

Artifact:[androidx.core:core](https://developer.android.com/jetpack/androidx/releases/core)  
[View Source](https://cs.android.com/search?q=file:androidx/core/view/LayoutInflaterCompat.java+class:androidx.core.view.LayoutInflaterCompat)  
Added in[1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)

*** ** * ** ***

Kotlin\|[Java](https://developer.android.com/reference/androidx/core/view/LayoutInflaterCompat "View this page in Java")

<br />

```
class LayoutInflaterCompat
```

<br />

*** ** * ** ***

Helper for accessing features in[LayoutInflater](https://developer.android.com/reference/android/view/LayoutInflater.html).

## Summary

|                                                       ### Public functions                                                        |
|-----------------------------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `java-static `[LayoutInflaterFactory](https://developer.android.com/reference/kotlin/androidx/core/view/LayoutInflaterFactory)`!` | ~~[getFactory](https://developer.android.com/reference/kotlin/androidx/core/view/LayoutInflaterCompat#getFactory(android.view.LayoutInflater))~~`(inflater: `[LayoutInflater](https://developer.android.com/reference/android/view/LayoutInflater.html)`!)` **This function is deprecated.** Use[setFactory2](https://developer.android.com/reference/kotlin/androidx/core/view/LayoutInflaterCompat#setFactory2(android.view.LayoutInflater,android.view.LayoutInflater.Factory2))to set and[getFactory2](https://developer.android.com/reference/android/view/LayoutInflater.html#getFactory2())to get the factory. <br />                                                                                                                                                                              |
| `java-static `[Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html)                                       | ~~[setFactory](https://developer.android.com/reference/kotlin/androidx/core/view/LayoutInflaterCompat#setFactory(android.view.LayoutInflater,androidx.core.view.LayoutInflaterFactory))~~`(inflater: `[LayoutInflater](https://developer.android.com/reference/android/view/LayoutInflater.html)`, factory: `[LayoutInflaterFactory](https://developer.android.com/reference/kotlin/androidx/core/view/LayoutInflaterFactory)`)` **This function is deprecated.** Use[setFactory2](https://developer.android.com/reference/kotlin/androidx/core/view/LayoutInflaterCompat#setFactory2(android.view.LayoutInflater,android.view.LayoutInflater.Factory2))instead to set and[getFactory2](https://developer.android.com/reference/android/view/LayoutInflater.html#getFactory2())to get the factory. <br /> |
| `java-static `[Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html)                                       | [setFactory2](https://developer.android.com/reference/kotlin/androidx/core/view/LayoutInflaterCompat#setFactory2(android.view.LayoutInflater,android.view.LayoutInflater.Factory2))`(inflater: `[LayoutInflater](https://developer.android.com/reference/android/view/LayoutInflater.html)`, factory: `[LayoutInflater.Factory2](https://developer.android.com/reference/android/view/LayoutInflater.Factory2.html)`)` Attach a custom[LayoutInflater.Factory2](https://developer.android.com/reference/android/view/LayoutInflater.Factory2.html)for creating views while using this[LayoutInflater](https://developer.android.com/reference/android/view/LayoutInflater.html).                                                                                                                          |

## Public functions

### getFactory

Added in[1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)  
Deprecated in[1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)  

```
java-static fun [getFactory](https://developer.android.com/reference/kotlin/androidx/core/view/LayoutInflaterCompat#getFactory(android.view.LayoutInflater))(inflater: LayoutInflater!): LayoutInflaterFactory!
```
| **This function is deprecated.**   
|
| Use[setFactory2](https://developer.android.com/reference/kotlin/androidx/core/view/LayoutInflaterCompat#setFactory2(android.view.LayoutInflater,android.view.LayoutInflater.Factory2))to set and[getFactory2](https://developer.android.com/reference/android/view/LayoutInflater.html#getFactory2())to get the factory.

Return the current[LayoutInflaterFactory](https://developer.android.com/reference/kotlin/androidx/core/view/LayoutInflaterFactory)(or null). This is called on each element name. If the factory returns a View, add that to the hierarchy. If it returns null, proceed to call onCreateView(name).  

|                                                       Returns                                                       |
|---------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [LayoutInflaterFactory](https://developer.android.com/reference/kotlin/androidx/core/view/LayoutInflaterFactory)`!` | The[LayoutInflaterFactory](https://developer.android.com/reference/kotlin/androidx/core/view/LayoutInflaterFactory)associated with the[LayoutInflater](https://developer.android.com/reference/android/view/LayoutInflater.html). Will be`null`if the inflater does not have a[LayoutInflaterFactory](https://developer.android.com/reference/kotlin/androidx/core/view/LayoutInflaterFactory)but a raw[LayoutInflater.Factory](https://developer.android.com/reference/android/view/LayoutInflater.Factory.html). |

|                                              See also                                               |
|-----------------------------------------------------------------------------------------------------|---|
| [getFactory](https://developer.android.com/reference/android/view/LayoutInflater.html#getFactory()) |   |

### setFactory

Added in[1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)  
Deprecated in[1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)  

```
java-static fun [setFactory](https://developer.android.com/reference/kotlin/androidx/core/view/LayoutInflaterCompat#setFactory(android.view.LayoutInflater,androidx.core.view.LayoutInflaterFactory))(inflater: LayoutInflater, factory: LayoutInflaterFactory): Unit
```
| **This function is deprecated.**   
|
| Use[setFactory2](https://developer.android.com/reference/kotlin/androidx/core/view/LayoutInflaterCompat#setFactory2(android.view.LayoutInflater,android.view.LayoutInflater.Factory2))instead to set and[getFactory2](https://developer.android.com/reference/android/view/LayoutInflater.html#getFactory2())to get the factory.

Attach a custom Factory interface for creating views while using this LayoutInflater. This must not be null, and can only be set once; after setting, you can not change the factory.  

|                                                                See also                                                                |
|----------------------------------------------------------------------------------------------------------------------------------------|---|
| [setFactory](https://developer.android.com/reference/android/view/LayoutInflater.html#setFactory(android.view.LayoutInflater.Factory)) |   |

### setFactory2

Added in[1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)  

```
java-static fun setFactory2(inflater: LayoutInflater, factory: LayoutInflater.Factory2): Unit
```

Attach a custom[LayoutInflater.Factory2](https://developer.android.com/reference/android/view/LayoutInflater.Factory2.html)for creating views while using this[LayoutInflater](https://developer.android.com/reference/android/view/LayoutInflater.html). This must not be null, and can only be set once; after setting, you can not change the factory.  

|                                                                 See also                                                                  |
|-------------------------------------------------------------------------------------------------------------------------------------------|---|
| [setFactory2](https://developer.android.com/reference/android/view/LayoutInflater.html#setFactory2(android.view.LayoutInflater.Factory2)) |   |