Attribute

public abstract @interface Attribute
implements Annotation

androidx.resourceinspection.annotation.Attribute


Map a getter to its Android resources attribute.

This annotation is consumed by the androidx.resourceinspection:resourceinspection-processor annotation processor to map a getter on a custom View back to its XML attribute name and ID. This enables Android Studio's layout inspection tool to read the runtime values of the attributes of a custom View.

Summary

Nested classes

@interface Attribute.IntMap

One entry in a mapping of int values to enum or flag names. 

Public methods

IntMap[] intMapping()

Map semantic names to int values.

String value()

The full name of the attribute, including namespace.

Inherited methods

Public methods

intMapping

public IntMap[] intMapping ()

Map semantic names to int values.

Populating this field with an array of Attribute.IntMap entries provides the layout inspection tool with the semantic names of enumerations stored as integers, instead of the numeric value. This is used for attributes with an IntDef mapping to flags or enumerations.

By default, the annotation processor assumes that the mapping defines an enumeration. If any one of the entries has its Attribute.IntMap.mask() set, the mapping will be interpreted as flags.

Returns
IntMap[] an array of map entries

value

public String value ()

The full name of the attribute, including namespace.

For example: "android:color" or "my.library:myAttribute".

Returns
String the attribute name