Colors
class Colors
Summary
Public constructors |
|---|
Public functions |
|
|---|---|
Colors |
copy(Returns a copy of this Colors, optionally overriding some of the values. |
open String |
toString() |
Extension functions |
|
|---|---|
Color |
Colors.contentColorFor(backgroundColor: Color)The Material color system contains pairs of colors that are typically used for the background and content color inside a component. |
Public constructors
Colors
Colors(
primary: Color = Color(0xFFAECBFA),
primaryVariant: Color = Color(0xFF8AB4F8),
secondary: Color = Color(0xFFFDE293),
secondaryVariant: Color = Color(0xFF594F33),
background: Color = Color.Black,
surface: Color = Color(0xFF303133),
error: Color = Color(0xFFEE675C),
onPrimary: Color = Color(0xFF303133),
onSecondary: Color = Color(0xFF303133),
onBackground: Color = Color.White,
onSurface: Color = Color.White,
onSurfaceVariant: Color = Color(0xFFDADCE0),
onError: Color = Color(0xFF000000)
)
Public functions
copy
fun copy(
primary: Color = this.primary,
primaryVariant: Color = this.primaryVariant,
secondary: Color = this.secondary,
secondaryVariant: Color = this.secondaryVariant,
background: Color = this.background,
surface: Color = this.surface,
error: Color = this.error,
onPrimary: Color = this.onPrimary,
onSecondary: Color = this.onSecondary,
onBackground: Color = this.onBackground,
onSurface: Color = this.onSurface,
onSurfaceVariant: Color = this.onSurfaceVariant,
onError: Color = this.onError
): Colors
Returns a copy of this Colors, optionally overriding some of the values.
Public properties
Extension functions
contentColorFor
fun Colors.contentColorFor(backgroundColor: Color): Color
The Material color system contains pairs of colors that are typically used for the background and content color inside a component. For example, a Button typically uses primary for its background, and onPrimary for the color of its content (usually text or iconography).
This function tries to match the provided backgroundColor to a 'background' color in this Colors, and then will return the corresponding color used for content. For example, when backgroundColor is Colors.primary, this will return Colors.onPrimary.
If backgroundColor does not match a background color in the theme, this will return Color.Unspecified.
| Returns | |
|---|---|
Color |
the matching content color for |
| See also | |
|---|---|
contentColorFor |