Class SurfaceColor
A color used on an external surface. Because surfaces render outside the app (potentially while the app process is dead) they cannot resolve theme constants at render time, so a surface color is either an explicit ARGB value with an optional dark-mode counterpart, or a semantic role the operating system resolves natively (label, secondary label, background, accent).
SurfaceColor.rgb(0xff333333, 0xffeeeeee) // dark text in light mode, light text in dark mode
SurfaceColor.LABEL // whatever the OS considers primary label color
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final SurfaceColorThe platform accent / tint color.static final SurfaceColorThe platform's standard surface background color.static final SurfaceColorThe platform's primary label (body text) color.static final SurfaceColorThe platform's secondary (dimmed) label color. -
Method Summary
Modifier and TypeMethodDescriptionintgetDark()Returns the dark-mode ARGB value; meaningless for role colors.intgetLight()Returns the light-mode ARGB value; meaningless for role colors.getRole()Returns the semantic role name (label,secondaryLabel,background,accent), or null for explicit ARGB colors.static SurfaceColorrgb(int argb) Creates a color used in both light and dark appearance.static SurfaceColorrgb(int lightArgb, int darkArgb) Creates a color with distinct light and dark appearance values.
-
Field Details
-
LABEL
The platform's primary label (body text) color. -
SECONDARY_LABEL
The platform's secondary (dimmed) label color. -
BACKGROUND
The platform's standard surface background color. -
ACCENT
The platform accent / tint color.
-
-
Method Details
-
rgb
Creates a color used in both light and dark appearance. The alpha byte is honored verbatim by every renderer: pass
0xFFRRGGBBfor an opaque color -- a value with a zero alpha byte (e.g. a plain0xRRGGBBliteral) is fully transparent and draws nothing.Parameters
argb: the color as0xAARRGGBB
Returns
the color
-
rgb
Creates a color with distinct light and dark appearance values. The surface renderer picks the value matching the system appearance. The alpha byte is honored verbatim: pass
0xFFRRGGBBfor opaque colors.Parameters
lightArgb: the color used in light mode as0xAARRGGBBdarkArgb: the color used in dark mode as0xAARRGGBB
Returns
the color
-
getLight
public int getLight()Returns the light-mode ARGB value; meaningless for role colors. -
getDark
public int getDark()Returns the dark-mode ARGB value; meaningless for role colors. -
getRole
Returns the semantic role name (label,secondaryLabel,background,accent), or null for explicit ARGB colors.
-