# AppCompatViewInflater

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

*** ** * ** ***


```
public class AppCompatViewInflater
```

<br />

Known direct subclasses [LeanbackAppCompatViewInflater](https://developer.android.com/reference/androidx/leanback/widget/LeanbackAppCompatViewInflater)

|---|---|
| `https://developer.android.com/reference/androidx/leanback/widget/LeanbackAppCompatViewInflater` | Inflater that converts leanback non-AppCpmpat views in layout to AppCompat versions. |

*** ** * ** ***

This class is used by AppCompat to automatically "substitute" all usages of core Android widgets inflated from layout files by the AppCompat extensions of those widgets.

This class two main responsibilities: the first is to 'inject' our tinted views in place of the framework versions in layout inflation; the second is backport the `android:theme` functionality for any inflated widgets. This include theme inheritance from its parent.

In order to provide your own extensions, follow these steps:

- Extend this class, or the relevant subclass if you're using the Material components library
- Override one or more of the `createXYZ` methods
- Add the `viewInflaterClass` attribute on your application theme. The value of the attribute should be the fully-qualified class name of your custom inflater class.

## Summary

| ### Public constructors |
|---|
| `https://developer.android.com/reference/androidx/appcompat/app/AppCompatViewInflater#AppCompatViewInflater()()` |

| ### Public methods |
|---|---|
| `final @https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/android/view/View.html` | `https://developer.android.com/reference/androidx/appcompat/app/AppCompatViewInflater#createView(android.view.View,java.lang.String,android.content.Context,android.util.AttributeSet,boolean,boolean,boolean,boolean)( @https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/android/view/View.html parent, @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/lang/String.html name, @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/content/Context.html context, @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/util/AttributeSet.html attrs, boolean inheritContext, boolean readAndroidTheme, boolean readAppTheme, boolean wrapContext )` Creates an AppCompat-compatible widget by automatically "substituting" all usages of core Android widgets with the AppCompat extensions of those widgets. |

| ### Protected methods |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/appcompat/widget/AppCompatAutoCompleteTextView` | `https://developer.android.com/reference/androidx/appcompat/app/AppCompatViewInflater#createAutoCompleteTextView(android.content.Context,android.util.AttributeSet)(https://developer.android.com/reference/android/content/Context.html context, https://developer.android.com/reference/android/util/AttributeSet.html attrs)` |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/appcompat/widget/AppCompatButton` | `https://developer.android.com/reference/androidx/appcompat/app/AppCompatViewInflater#createButton(android.content.Context,android.util.AttributeSet)(https://developer.android.com/reference/android/content/Context.html context, https://developer.android.com/reference/android/util/AttributeSet.html attrs)` |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/appcompat/widget/AppCompatCheckBox` | `https://developer.android.com/reference/androidx/appcompat/app/AppCompatViewInflater#createCheckBox(android.content.Context,android.util.AttributeSet)(https://developer.android.com/reference/android/content/Context.html context, https://developer.android.com/reference/android/util/AttributeSet.html attrs)` |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/appcompat/widget/AppCompatCheckedTextView` | `https://developer.android.com/reference/androidx/appcompat/app/AppCompatViewInflater#createCheckedTextView(android.content.Context,android.util.AttributeSet)(https://developer.android.com/reference/android/content/Context.html context, https://developer.android.com/reference/android/util/AttributeSet.html attrs)` |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/appcompat/widget/AppCompatEditText` | `https://developer.android.com/reference/androidx/appcompat/app/AppCompatViewInflater#createEditText(android.content.Context,android.util.AttributeSet)(https://developer.android.com/reference/android/content/Context.html context, https://developer.android.com/reference/android/util/AttributeSet.html attrs)` |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/appcompat/widget/AppCompatImageButton` | `https://developer.android.com/reference/androidx/appcompat/app/AppCompatViewInflater#createImageButton(android.content.Context,android.util.AttributeSet)(https://developer.android.com/reference/android/content/Context.html context, https://developer.android.com/reference/android/util/AttributeSet.html attrs)` |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/appcompat/widget/AppCompatImageView` | `https://developer.android.com/reference/androidx/appcompat/app/AppCompatViewInflater#createImageView(android.content.Context,android.util.AttributeSet)(https://developer.android.com/reference/android/content/Context.html context, https://developer.android.com/reference/android/util/AttributeSet.html attrs)` |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/appcompat/widget/AppCompatMultiAutoCompleteTextView` | `https://developer.android.com/reference/androidx/appcompat/app/AppCompatViewInflater#createMultiAutoCompleteTextView(android.content.Context,android.util.AttributeSet)(https://developer.android.com/reference/android/content/Context.html context, https://developer.android.com/reference/android/util/AttributeSet.html attrs)` |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/appcompat/widget/AppCompatRadioButton` | `https://developer.android.com/reference/androidx/appcompat/app/AppCompatViewInflater#createRadioButton(android.content.Context,android.util.AttributeSet)(https://developer.android.com/reference/android/content/Context.html context, https://developer.android.com/reference/android/util/AttributeSet.html attrs)` |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/appcompat/widget/AppCompatRatingBar` | `https://developer.android.com/reference/androidx/appcompat/app/AppCompatViewInflater#createRatingBar(android.content.Context,android.util.AttributeSet)(https://developer.android.com/reference/android/content/Context.html context, https://developer.android.com/reference/android/util/AttributeSet.html attrs)` |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/appcompat/widget/AppCompatSeekBar` | `https://developer.android.com/reference/androidx/appcompat/app/AppCompatViewInflater#createSeekBar(android.content.Context,android.util.AttributeSet)(https://developer.android.com/reference/android/content/Context.html context, https://developer.android.com/reference/android/util/AttributeSet.html attrs)` |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/appcompat/widget/AppCompatSpinner` | `https://developer.android.com/reference/androidx/appcompat/app/AppCompatViewInflater#createSpinner(android.content.Context,android.util.AttributeSet)(https://developer.android.com/reference/android/content/Context.html context, https://developer.android.com/reference/android/util/AttributeSet.html attrs)` |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/appcompat/widget/AppCompatTextView` | `https://developer.android.com/reference/androidx/appcompat/app/AppCompatViewInflater#createTextView(android.content.Context,android.util.AttributeSet)(https://developer.android.com/reference/android/content/Context.html context, https://developer.android.com/reference/android/util/AttributeSet.html attrs)` |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/appcompat/widget/AppCompatToggleButton` | `https://developer.android.com/reference/androidx/appcompat/app/AppCompatViewInflater#createToggleButton(android.content.Context,android.util.AttributeSet)(https://developer.android.com/reference/android/content/Context.html context, https://developer.android.com/reference/android/util/AttributeSet.html attrs)` |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/android/view/View.html` | `https://developer.android.com/reference/androidx/appcompat/app/AppCompatViewInflater#createView(android.content.Context,java.lang.String,android.util.AttributeSet)(https://developer.android.com/reference/android/content/Context.html context, https://developer.android.com/reference/java/lang/String.html name, https://developer.android.com/reference/android/util/AttributeSet.html attrs)` |

## Public constructors

### AppCompatViewInflater

Added in 1.1.0

```
public AppCompatViewInflater()
```

## Public methods

### createView

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

```
public final @Nullable View createView(
    @Nullable View parent,
    @NonNull String name,
    @NonNull Context context,
    @NonNull AttributeSet attrs,
    boolean inheritContext,
    boolean readAndroidTheme,
    boolean readAppTheme,
    boolean wrapContext
)
```

Creates an AppCompat-compatible widget by automatically "substituting" all usages of core Android widgets with the AppCompat extensions of those widgets.

Most developers should not call this method directly. Instead, use the layout inflater provided by `https://developer.android.com/reference/android/app/Activity.html#getLayoutInflater()` or call `https://developer.android.com/reference/androidx/appcompat/app/AppCompatDelegate#createView(android.view.View,java.lang.String,android.content.Context,android.util.AttributeSet)`.

| Parameters |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/android/view/View.html parent` | the hierarchical parent of the view, if any |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/lang/String.html name` | class name of the view, must be a simple class name like `TextView` for core Android widgets |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/content/Context.html context` | context against which the view should be constructed, may be wrapped for theming purposes or fully replaced if `inheritContext` is `true` |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/util/AttributeSet.html attrs` | attribute set to pass to the view constructor |
| `boolean inheritContext` | `true` to construct the view against the `parent` view's context instead of `context`, or `false` to use `context` |
| `boolean readAndroidTheme` | `true` to parse `android:theme` from `attrs` and wrap the view's construction context if necessary |
| `boolean readAppTheme` | `true` to parse `app:theme` from `attrs` and wrap the view's construction context if necessary |
| `boolean wrapContext` | this parameter is ignored |

| Returns |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/android/view/View.html` | an AppCompat-compatible widget |

## Protected methods

### createAutoCompleteTextView

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

```
protected @NonNull AppCompatAutoCompleteTextView createAutoCompleteTextView(Context context, AttributeSet attrs)
```

### createButton

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

```
protected @NonNull AppCompatButton createButton(Context context, AttributeSet attrs)
```

### createCheckBox

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

```
protected @NonNull AppCompatCheckBox createCheckBox(Context context, AttributeSet attrs)
```

### createCheckedTextView

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

```
protected @NonNull AppCompatCheckedTextView createCheckedTextView(Context context, AttributeSet attrs)
```

### createEditText

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

```
protected @NonNull AppCompatEditText createEditText(Context context, AttributeSet attrs)
```

### createImageButton

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

```
protected @NonNull AppCompatImageButton createImageButton(Context context, AttributeSet attrs)
```

### createImageView

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

```
protected @NonNull AppCompatImageView createImageView(Context context, AttributeSet attrs)
```

### createMultiAutoCompleteTextView

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

```
protected @NonNull AppCompatMultiAutoCompleteTextView createMultiAutoCompleteTextView(Context context, AttributeSet attrs)
```

### createRadioButton

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

```
protected @NonNull AppCompatRadioButton createRadioButton(Context context, AttributeSet attrs)
```

### createRatingBar

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

```
protected @NonNull AppCompatRatingBar createRatingBar(Context context, AttributeSet attrs)
```

### createSeekBar

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

```
protected @NonNull AppCompatSeekBar createSeekBar(Context context, AttributeSet attrs)
```

### createSpinner

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

```
protected @NonNull AppCompatSpinner createSpinner(Context context, AttributeSet attrs)
```

### createTextView

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

```
protected @NonNull AppCompatTextView createTextView(Context context, AttributeSet attrs)
```

### createToggleButton

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

```
protected @NonNull AppCompatToggleButton createToggleButton(Context context, AttributeSet attrs)
```

### createView

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

```
protected @Nullable View createView(Context context, String name, AttributeSet attrs)
```