obtain Styled Attributes
open fun obtainStyledAttributes(@NonNull context: Context, set: AttributeSet, @NonNull @StyleableRes attrs: Array<Int>, @AttrRes defStyleAttr: Int, @StyleRes defStyleRes: Int, @StyleableRes textAppearanceResIndices: Array<Int>): TypedArray
Safely retrieve styled attribute information in this Context's theme, after checking whether the theme is compatible with the component's given style.
Set a component's enforceMaterialTheme
attribute to true
to ensure that the Context's theme inherits from Theme.MaterialComponents
. For example, you'll want to do this if the component uses a new attribute defined in
Theme.MaterialComponents
like colorSecondary
.
If the enforceTextAppearance
attribute is set to true
and textAppearanceResIndices parameter is specified and has non-negative values, this will also check that a valid TextAppearance is set on this component for the text appearance resources passed in.