# 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)

*** ** * ** ***


```
public final class LayoutInflaterCompat
```

<br />

*** ** * ** ***

Helper for accessing features in `https://developer.android.com/reference/android/view/LayoutInflater.html`.

## Summary

| ### Public methods |
|---|---|
| `static https://developer.android.com/reference/androidx/core/view/LayoutInflaterFactory` | `[getFactory](https://developer.android.com/reference/androidx/core/view/LayoutInflaterCompat#getFactory(android.view.LayoutInflater))(https://developer.android.com/reference/android/view/LayoutInflater.html inflater)` **This method is deprecated.** Use `https://developer.android.com/reference/androidx/core/view/LayoutInflaterCompat#setFactory2(android.view.LayoutInflater,android.view.LayoutInflater.Factory2)` to set and `https://developer.android.com/reference/android/view/LayoutInflater.html#getFactory2()` to get the factory. <br /> |
| `static void` | `[setFactory](https://developer.android.com/reference/androidx/core/view/LayoutInflaterCompat#setFactory(android.view.LayoutInflater,androidx.core.view.LayoutInflaterFactory))( @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/view/LayoutInflater.html inflater, @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/core/view/LayoutInflaterFactory factory )` **This method is deprecated.** Use `https://developer.android.com/reference/androidx/core/view/LayoutInflaterCompat#setFactory2(android.view.LayoutInflater,android.view.LayoutInflater.Factory2)` instead to set and `https://developer.android.com/reference/android/view/LayoutInflater.html#getFactory2()` to get the factory. <br /> |
| `static void` | `https://developer.android.com/reference/androidx/core/view/LayoutInflaterCompat#setFactory2(android.view.LayoutInflater,android.view.LayoutInflater.Factory2)( @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/view/LayoutInflater.html inflater, @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/view/LayoutInflater.Factory2.html factory )` Attach a custom `https://developer.android.com/reference/android/view/LayoutInflater.Factory2.html` for creating views while using this `https://developer.android.com/reference/android/view/LayoutInflater.html`. |

## Public methods

### 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)

```
public static LayoutInflaterFactory [getFactory](https://developer.android.com/reference/androidx/core/view/LayoutInflaterCompat#getFactory(android.view.LayoutInflater))(LayoutInflater inflater)
```

> [!CAUTION]
> **This method is deprecated.**   
>
> Use `https://developer.android.com/reference/androidx/core/view/LayoutInflaterCompat#setFactory2(android.view.LayoutInflater,android.view.LayoutInflater.Factory2)` to set and `https://developer.android.com/reference/android/view/LayoutInflater.html#getFactory2()` to get the factory.

Return the current `https://developer.android.com/reference/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 |
|---|---|
| `https://developer.android.com/reference/androidx/core/view/LayoutInflaterFactory` | The `https://developer.android.com/reference/androidx/core/view/LayoutInflaterFactory` associated with the `https://developer.android.com/reference/android/view/LayoutInflater.html`. Will be `null` if the inflater does not have a `https://developer.android.com/reference/androidx/core/view/LayoutInflaterFactory` but a raw `https://developer.android.com/reference/android/view/LayoutInflater.Factory.html`. |

| See also |
|---|---|
| `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)

```
public static void [setFactory](https://developer.android.com/reference/androidx/core/view/LayoutInflaterCompat#setFactory(android.view.LayoutInflater,androidx.core.view.LayoutInflaterFactory))(
    @NonNull LayoutInflater inflater,
    @NonNull LayoutInflaterFactory factory
)
```

> [!CAUTION]
> **This method is deprecated.**   
>
> Use `https://developer.android.com/reference/androidx/core/view/LayoutInflaterCompat#setFactory2(android.view.LayoutInflater,android.view.LayoutInflater.Factory2)` instead to set and `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 |
|---|---|
| `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)

```
public static void setFactory2(
    @NonNull LayoutInflater inflater,
    @NonNull LayoutInflater.Factory2 factory
)
```

Attach a custom `https://developer.android.com/reference/android/view/LayoutInflater.Factory2.html` for creating views while using this `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 |
|---|---|
| `https://developer.android.com/reference/android/view/LayoutInflater.html#setFactory2(android.view.LayoutInflater.Factory2)` |   |