MaterialColors

open class MaterialColors

A utility class for common color variants used in Material themes.

Properties

Link copied to clipboard
val ALPHA_DISABLED: Float = 0.38f
Link copied to clipboard
Link copied to clipboard
val ALPHA_FULL: Float = 1.0f
Link copied to clipboard
val ALPHA_LOW: Float = 0.32f
Link copied to clipboard
val ALPHA_MEDIUM: Float = 0.54f

Functions

Link copied to clipboard
open fun compositeARGBWithAlpha(@ColorInt originalARGB: Int, @IntRange(from = 0, to = 255) alpha: Int): Int
Calculates a new color by multiplying an additional alpha int value to the alpha channel of a color in integer type.
Link copied to clipboard
open fun getColor(@NonNull view: View, @AttrRes colorAttributeResId: Int): Int
Returns the color int for the provided theme color attribute, using the Context of the provided view.
open fun getColor(@NonNull context: Context, @AttrRes colorAttributeResId: Int, @ColorInt defaultValue: Int): Int
Returns the color int for the provided theme color attribute, or the default value if the attribute is not set in the current theme.
open fun getColor(context: Context, @AttrRes colorAttributeResId: Int, errorMessageComponent: String): Int
Returns the color int for the provided theme color attribute.
open fun getColor(@NonNull view: View, @AttrRes colorAttributeResId: Int, @ColorInt defaultValue: Int): Int
Returns the color int for the provided theme color attribute, or the default value if the attribute is not set in the current theme, using the view's Context.
Link copied to clipboard
open fun getColorOrNull(@NonNull context: Context, @AttrRes colorAttributeResId: Int): Integer
Returns the color int for the provided theme color attribute, or null if the attribute is not set in the current theme.
Link copied to clipboard
open fun getColorRoles(@NonNull context: Context, @ColorInt color: Int): ColorRoles
open fun getColorRoles(@ColorInt color: Int, isLightTheme: Boolean): ColorRoles
Returns the ColorRoles object generated from the provided input color.
Link copied to clipboard
open fun getColorStateList(@NonNull context: Context, @AttrRes colorAttributeResId: Int, @NonNull defaultValue: ColorStateList): ColorStateList
Returns the color state list for the provided theme color attribute, or the default value if the attribute is not set in the current theme.
Link copied to clipboard
open fun getColorStateListOrNull(@NonNull context: Context, @AttrRes colorAttributeResId: Int): ColorStateList
Returns the color state list for the provided theme color attribute, or null if the attribute is not set in the current theme.
Link copied to clipboard
Returns the color int of the surface container color role, based on the provided input color.
Link copied to clipboard
Returns the color int of the surface container high color role, based on the provided input color.
Link copied to clipboard
open fun harmonize(@ColorInt colorToHarmonize: Int, @ColorInt colorToHarmonizeWith: Int): Int
A convenience function to harmonize any two colors provided, returns the color int of the harmonized color, or the original design color value if color harmonization is not available.
Link copied to clipboard
open fun harmonizeWithPrimary(@NonNull context: Context, @ColorInt colorToHarmonize: Int): Int
Returns the color int of the given color harmonized with the context theme's colorPrimary.
Link copied to clipboard
open fun isColorLight(@ColorInt color: Int): Boolean
Determines if a color should be considered light or dark.
Link copied to clipboard
open fun layer(@ColorInt backgroundColor: Int, @ColorInt overlayColor: Int): Int
Calculates a color that represents the layering of the overlayColor on top of the backgroundColor.
open fun layer(@NonNull view: View, @AttrRes backgroundColorAttributeResId: Int, @AttrRes overlayColorAttributeResId: Int): Int
Convenience method that calculates layer without an overlayAlpha value by passing in 1f for the alpha value.
open fun layer(@ColorInt backgroundColor: Int, @ColorInt overlayColor: Int, @FloatRange(from = 0.0, to = 1.0) overlayAlpha: Float): Int
Calculates a color that represents the layering of the overlayColor (with overlayAlpha applied) on top of the backgroundColor.
open fun layer(@NonNull view: View, @AttrRes backgroundColorAttributeResId: Int, @AttrRes overlayColorAttributeResId: Int, @FloatRange(from = 0.0, to = 1.0) overlayAlpha: Float): Int
Convenience method that wraps layer for layering colors from theme attributes.