# 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)

*** ** * ** ***


```
@Retention(value = RetentionPolicy.SOURCE)
@Target(value = ElementType.METHOD)
public 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 `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 `https://developer.android.com/reference/android/view/View.html`.

## Summary

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

| ### Public methods |
|---|---|
| `abstract @https://developer.android.com/reference/androidx/annotation/NonNull Attribute.IntMap[]` | `https://developer.android.com/reference/androidx/resourceinspection/annotation/Attribute#intMapping()()` Map semantic names to int values. |
| `abstract @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/androidx/resourceinspection/annotation/Attribute#value()()` The full name of the attribute, including namespace. |

## Public methods

### intMapping

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

```
public abstract @NonNull Attribute.IntMap[] intMapping()
```

Map semantic names to int values.

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

| Returns |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull Attribute.IntMap[]` | an array of map entries |

### value

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

```
public abstract @NonNull String value()
```

The full name of the attribute, including namespace.

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

| Returns |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html` | the attribute name |