Google 致力于为黑人社区推动种族平等。查看具体举措

AppCompatViewInflater

public class AppCompatViewInflater
extends Object

java.lang.Object
   ↳ androidx.appcompat.app.AppCompatViewInflater


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

AppCompatViewInflater()

Protected methods

AppCompatAutoCompleteTextView createAutoCompleteTextView(Context context, AttributeSet attrs)
AppCompatButton createButton(Context context, AttributeSet attrs)
AppCompatCheckBox createCheckBox(Context context, AttributeSet attrs)
AppCompatCheckedTextView createCheckedTextView(Context context, AttributeSet attrs)
AppCompatEditText createEditText(Context context, AttributeSet attrs)
AppCompatImageButton createImageButton(Context context, AttributeSet attrs)
AppCompatImageView createImageView(Context context, AttributeSet attrs)
AppCompatMultiAutoCompleteTextView createMultiAutoCompleteTextView(Context context, AttributeSet attrs)
AppCompatRadioButton createRadioButton(Context context, AttributeSet attrs)
AppCompatRatingBar createRatingBar(Context context, AttributeSet attrs)
AppCompatSeekBar createSeekBar(Context context, AttributeSet attrs)
AppCompatSpinner createSpinner(Context context, AttributeSet attrs)
AppCompatTextView createTextView(Context context, AttributeSet attrs)
AppCompatToggleButton createToggleButton(Context context, AttributeSet attrs)
View createView(Context context, String name, AttributeSet attrs)

Inherited methods

Public constructors

AppCompatViewInflater

public AppCompatViewInflater ()

Protected methods

createAutoCompleteTextView

protected AppCompatAutoCompleteTextView createAutoCompleteTextView (Context context, 
                AttributeSet attrs)

Parameters
context Context

attrs AttributeSet

Returns
AppCompatAutoCompleteTextView

createButton

protected AppCompatButton createButton (Context context, 
                AttributeSet attrs)

Parameters
context Context

attrs AttributeSet

Returns
AppCompatButton

createCheckBox

protected AppCompatCheckBox createCheckBox (Context context, 
                AttributeSet attrs)

Parameters
context Context

attrs AttributeSet

Returns
AppCompatCheckBox

createCheckedTextView

protected AppCompatCheckedTextView createCheckedTextView (Context context, 
                AttributeSet attrs)

Parameters
context Context

attrs AttributeSet

Returns
AppCompatCheckedTextView

createEditText

protected AppCompatEditText createEditText (Context context, 
                AttributeSet attrs)

Parameters
context Context

attrs AttributeSet

Returns
AppCompatEditText

createImageButton

protected AppCompatImageButton createImageButton (Context context, 
                AttributeSet attrs)

Parameters
context Context

attrs AttributeSet

Returns
AppCompatImageButton

createImageView

protected AppCompatImageView createImageView (Context context, 
                AttributeSet attrs)

Parameters
context Context

attrs AttributeSet

Returns
AppCompatImageView

createMultiAutoCompleteTextView

protected AppCompatMultiAutoCompleteTextView createMultiAutoCompleteTextView (Context context, 
                AttributeSet attrs)

Parameters
context Context

attrs AttributeSet

Returns
AppCompatMultiAutoCompleteTextView

createRadioButton

protected AppCompatRadioButton createRadioButton (Context context, 
                AttributeSet attrs)

Parameters
context Context

attrs AttributeSet

Returns
AppCompatRadioButton

createRatingBar

protected AppCompatRatingBar createRatingBar (Context context, 
                AttributeSet attrs)

Parameters
context Context

attrs AttributeSet

Returns
AppCompatRatingBar

createSeekBar

protected AppCompatSeekBar createSeekBar (Context context, 
                AttributeSet attrs)

Parameters
context Context

attrs AttributeSet

Returns
AppCompatSeekBar

createSpinner

protected AppCompatSpinner createSpinner (Context context, 
                AttributeSet attrs)

Parameters
context Context

attrs AttributeSet

Returns
AppCompatSpinner

createTextView

protected AppCompatTextView createTextView (Context context, 
                AttributeSet attrs)

Parameters
context Context

attrs AttributeSet

Returns
AppCompatTextView

createToggleButton

protected AppCompatToggleButton createToggleButton (Context context, 
                AttributeSet attrs)

Parameters
context Context

attrs AttributeSet

Returns
AppCompatToggleButton

createView

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

Parameters
context Context

name String

attrs AttributeSet

Returns
View