AppCompatViewInflater
public class AppCompatViewInflater
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
createXYZmethods - Add the
viewInflaterClassattribute on your application theme. The value of the attribute should be the fully-qualified class name of your custom inflater class.
Summary
Public constructors |
|---|
Public methods |
|
|---|---|
final @Nullable View |
createView(Creates an AppCompat-compatible widget by automatically "substituting" all usages of core Android widgets with the AppCompat extensions of those widgets. |
Public constructors
Public methods
createView
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 getLayoutInflater or call createView.
| Parameters | |
|---|---|
@Nullable View parent |
the hierarchical parent of the view, if any |
@NonNull String name |
class name of the view, must be a simple class name like |
@NonNull Context context |
context against which the view should be constructed, may be wrapped for theming purposes or fully replaced if |
@NonNull AttributeSet attrs |
attribute set to pass to the view constructor |
boolean inheritContext |
|
boolean readAndroidTheme |
|
boolean readAppTheme |
|
boolean wrapContext |
|
Protected methods
createAutoCompleteTextView
protected @NonNull AppCompatAutoCompleteTextView createAutoCompleteTextView(Context context, AttributeSet attrs)
createButton
protected @NonNull AppCompatButton createButton(Context context, AttributeSet attrs)
createCheckBox
protected @NonNull AppCompatCheckBox createCheckBox(Context context, AttributeSet attrs)
createCheckedTextView
protected @NonNull AppCompatCheckedTextView createCheckedTextView(Context context, AttributeSet attrs)
createEditText
protected @NonNull AppCompatEditText createEditText(Context context, AttributeSet attrs)
createImageButton
protected @NonNull AppCompatImageButton createImageButton(Context context, AttributeSet attrs)
createImageView
protected @NonNull AppCompatImageView createImageView(Context context, AttributeSet attrs)
createMultiAutoCompleteTextView
protected @NonNull AppCompatMultiAutoCompleteTextView createMultiAutoCompleteTextView(Context context, AttributeSet attrs)
createRadioButton
protected @NonNull AppCompatRadioButton createRadioButton(Context context, AttributeSet attrs)
createRatingBar
protected @NonNull AppCompatRatingBar createRatingBar(Context context, AttributeSet attrs)
createSeekBar
protected @NonNull AppCompatSeekBar createSeekBar(Context context, AttributeSet attrs)
createSpinner
protected @NonNull AppCompatSpinner createSpinner(Context context, AttributeSet attrs)
createTextView
protected @NonNull AppCompatTextView createTextView(Context context, AttributeSet attrs)
createToggleButton
protected @NonNull AppCompatToggleButton createToggleButton(Context context, AttributeSet attrs)
createView
protected @Nullable View createView(Context context, String name, AttributeSet attrs)