# Attribute

# Attribute

Artifact:[androidx.resourceinspection:resourceinspection-annotation](https://developer.android.com/jetpack/androidx/releases/resourceinspection)  
[View Source](https://cs.android.com/search?q=file:androidx/resourceinspection/annotation/Attribute.java+class:androidx.resourceinspection.annotation.Attribute)  
Added in[1.0.0](https://developer.android.com/jetpack/androidx/releases/resourceinspection#1.0.0)

*** ** * ** ***

Kotlin\|[Java](https://developer.android.com/reference/androidx/resourceinspection/annotation/Attribute "View this page in Java")

<br />

```
@Retention(value = RetentionPolicy.SOURCE)
@Target(value = ElementType.METHOD)
annotation Attribute
```

<br />

*** ** * ** ***

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[android.view.View](https://developer.android.com/reference/android/view/View.html)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[android.view.View](https://developer.android.com/reference/android/view/View.html).

## Summary

|                                                                                                                                                                                                                                                         ### Nested types                                                                                                                                                                                                                                                          |
|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `@`[Retention](https://developer.android.com/reference/java/lang/annotation/Retention.html)`(value = `[RetentionPolicy.SOURCE](https://developer.android.com/reference/java/lang/annotation/RetentionPolicy.html#SOURCE)`)` `@`[Target](https://developer.android.com/reference/java/lang/annotation/Target.html)`(value = )` `annotation `[Attribute.IntMap](https://developer.android.com/reference/kotlin/androidx/resourceinspection/annotation/Attribute.IntMap) One entry in a mapping of int values to enum or flag names. |

|                                                                                                    ### Public functions                                                                                                     |
|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `abstract `[Array](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-array/index.html)`<`[Attribute.IntMap](https://developer.android.com/reference/kotlin/androidx/resourceinspection/annotation/Attribute.IntMap)`!>` | [intMapping](https://developer.android.com/reference/kotlin/androidx/resourceinspection/annotation/Attribute#intMapping())`()` Map semantic names to int values.          |
| `abstract `[String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)                                                                                                                                | [value](https://developer.android.com/reference/kotlin/androidx/resourceinspection/annotation/Attribute#value())`()` The full name of the attribute, including namespace. |

## Public functions

### intMapping

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

```
abstract fun intMapping(): Array<Attribute.IntMap!>
```

Map semantic names to int values.

Populating this field with an array of[IntMap](https://developer.android.com/reference/kotlin/androidx/resourceinspection/annotation/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[androidx.annotation.IntDef](https://developer.android.com/reference/kotlin/androidx/annotation/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[mask](https://developer.android.com/reference/kotlin/androidx/resourceinspection/annotation/Attribute.IntMap#mask())set, the mapping will be interpreted as flags.  

|                                                                                                     Returns                                                                                                      |
|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-------------------------|
| [Array](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-array/index.html)`<`[Attribute.IntMap](https://developer.android.com/reference/kotlin/androidx/resourceinspection/annotation/Attribute.IntMap)`!>` | an array of map entries |

### value

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

```
abstract fun value(): String
```

The full name of the attribute, including namespace.

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

|                                      Returns                                      |
|-----------------------------------------------------------------------------------|--------------------|
| [String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html) | the attribute name |