HarmonizedColorAttributes
public
final
class
HarmonizedColorAttributes
extends Object
java.lang.Object | |
↳ | com.google.android.material.color.HarmonizedColorAttributes |
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 methods | |
---|---|
static
HarmonizedColorAttributes
|
create(int[] attributes, int themeOverlay)
Create |
static
HarmonizedColorAttributes
|
create(int[] attributes)
Create |
static
HarmonizedColorAttributes
|
createMaterialDefaults()
Create |
int[]
|
getAttributes()
Returns the array of color attributes for harmonization. |
int
|
getThemeOverlay()
Returns the custom theme overlay for harmonization, default is 0 if not specified. |
Inherited methods | |
---|---|
Public methods
create
public static HarmonizedColorAttributes create (int[] attributes, int themeOverlay)
Create 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.
Parameters | |
---|---|
attributes |
int |
themeOverlay |
int |
Returns | |
---|---|
HarmonizedColorAttributes |
create
public static HarmonizedColorAttributes create (int[] attributes)
Create 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
create(int[], int)
.
Parameters | |
---|---|
attributes |
int |
Returns | |
---|---|
HarmonizedColorAttributes |
createMaterialDefaults
public static HarmonizedColorAttributes createMaterialDefaults ()
Create 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.
Returns | |
---|---|
HarmonizedColorAttributes |
getAttributes
public int[] getAttributes ()
Returns the array of color attributes for harmonization.
Returns | |
---|---|
int[] |
getThemeOverlay
public int getThemeOverlay ()
Returns the custom theme overlay for harmonization, default is 0 if not specified.
Returns | |
---|---|
int |