Material Colors
A utility class for common color variants used in Material themes.
Properties
Functions
Link copied to clipboard
Link copied to clipboard
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
Link copied to clipboard
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
Link copied to clipboard
Link copied to clipboard
Determines if a color should be considered light or dark.
Link copied to clipboard
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.