# HarmonizedColorAttributes

[View Source](https://github.com/material-components/material-components-android/blob/1.14.0/lib/java/com/google/android/material/color/HarmonizedColorAttributes.java)

*** ** * ** ***


```
public final class HarmonizedColorAttributes
```

<br />

*** ** * ** ***

A class for specifying color attributes for harmonization, which contains an array of color attributes, with the option to specify a custom theme overlay.

## Summary

| ### Public fields |
|---|---|
| `final int[]` | `https://developer.android.com/reference/com/google/android/material/color/HarmonizedColorAttributes#attributes()` |
| `final int` | `https://developer.android.com/reference/com/google/android/material/color/HarmonizedColorAttributes#themeOverlay()` |

| ### Public methods |
|---|---|
| `static https://developer.android.com/reference/com/google/android/material/color/HarmonizedColorAttributes` | `https://developer.android.com/reference/com/google/android/material/color/HarmonizedColorAttributes#create(int[])(int[] attributes)` Create `https://developer.android.com/reference/com/google/android/material/color/HarmonizedColorAttributes` with an array of color attributes. |
| `static https://developer.android.com/reference/com/google/android/material/color/HarmonizedColorAttributes` | `https://developer.android.com/reference/com/google/android/material/color/HarmonizedColorAttributes#create(int[],int)(int[] attributes, int themeOverlay)` Create `https://developer.android.com/reference/com/google/android/material/color/HarmonizedColorAttributes` with a theme overlay, along with an array of attributes in the theme overlay. |
| `static https://developer.android.com/reference/com/google/android/material/color/HarmonizedColorAttributes` | `https://developer.android.com/reference/com/google/android/material/color/HarmonizedColorAttributes#createMaterialDefaults()()` Create `https://developer.android.com/reference/com/google/android/material/color/HarmonizedColorAttributes` with Material default, with Error colors being harmonized. |
| `int[]` | `https://developer.android.com/reference/com/google/android/material/color/HarmonizedColorAttributes#getAttributes()()` Returns the array of color attributes for harmonization. |
| `int` | `https://developer.android.com/reference/com/google/android/material/color/HarmonizedColorAttributes#getThemeOverlay()()` Returns the custom theme overlay for harmonization, default is 0 if not specified. |

## Public fields

### attributes

```
public final int[] attributes
```

### themeOverlay

```
public final int themeOverlay
```

## Public methods

### create

```
public static HarmonizedColorAttributes create(int[] attributes)
```

Create `https://developer.android.com/reference/com/google/android/material/color/HarmonizedColorAttributes` with an array of color attributes. If this is called, the resources pointed by the attributes will be resolved at runtime and harmonized. If you're concerned about accidentally overwriting color resources, see `https://developer.android.com/reference/com/google/android/material/color/HarmonizedColorAttributes#create(int[],int)`.

### create

```
public static HarmonizedColorAttributes create(int[] attributes, int themeOverlay)
```

Create `https://developer.android.com/reference/com/google/android/material/color/HarmonizedColorAttributes` with a theme overlay, along with an array of attributes in the theme overlay.

In this method, instead of the color resource that the color attribute is pointing to in the main theme/context being harmonized directly, the color resource in the theme overlay context will be replaced with the harmonized color attribute instead.

### createMaterialDefaults

```
public static HarmonizedColorAttributes createMaterialDefaults()
```

Create `https://developer.android.com/reference/com/google/android/material/color/HarmonizedColorAttributes` with Material default, with Error colors being harmonized.

Instead of directly overwriting the resources that \`colorError\`, \`colorOnError\`, \`colorErrorContainer\` and \`colorOnErrorContainer\` points to in the main theme/context, we would:

1. look up the resources values in the theme overlay \`Context\`. 2. retrieve the harmonized resources with Primary. 3. replace \`@color/material_harmonized_color_error\`, \`@color/material_harmonized_color_on_error\`, etc. with the harmonized resources.

That way the Error roles in the theme overlay would point to harmonized resources.

### getAttributes

```
public int[] getAttributes()
```

Returns the array of color attributes for harmonization.

### getThemeOverlay

```
public int getThemeOverlay()
```

Returns the custom theme overlay for harmonization, default is 0 if not specified.