public final class SurfaceColor
- Object
- 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
Fields
public static final SurfaceColor LABEL | The platform’s primary label (body text) color. |
public static final SurfaceColor SECONDARY_LABEL | The platform’s secondary (dimmed) label color. |
public static final SurfaceColor BACKGROUND | The platform’s standard surface background color. |
public static final SurfaceColor ACCENT | The platform accent / tint color. |
Methods
public static SurfaceColor rgb(int argb) | Creates a color used in both light and dark appearance. |
public static SurfaceColor rgb(int lightArgb, int darkArgb) | Creates a color with distinct light and dark appearance values. |
public int getLight() | Returns the light-mode ARGB value; meaningless for role colors. |
public int getDark() | Returns the dark-mode ARGB value; meaningless for role colors. |
public String getRole() | Returns the semantic role name (label, secondaryLabel, background, accent), or null for explicit ARGB colors. |
Inherited methods
Field details
LABEL
public static final SurfaceColor LABELThe platform’s primary label (body text) color.
SECONDARY_LABEL
public static final SurfaceColor SECONDARY_LABELThe platform’s secondary (dimmed) label color.
BACKGROUND
public static final SurfaceColor BACKGROUNDThe platform’s standard surface background color.
ACCENT
public static final SurfaceColor ACCENTThe platform accent / tint color.
Method details
rgb
public static SurfaceColor rgb(int argb)Creates a color used in both light and dark appearance. The alpha byte is honored
verbatim by every renderer: pass
0xFFRRGGBB for an opaque color – a value with a zero
alpha byte (e.g. a plain 0xRRGGBB literal) is fully transparent and draws nothing.Parameters
argbint- the color as
0xAARRGGBB
Returns
the color
rgb
public static SurfaceColor rgb(int lightArgb, int darkArgb)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
0xFFRRGGBB for opaque colors.Parameters
lightArgbint- the color used in light mode as
0xAARRGGBB darkArgbint- the color used in dark mode as
0xAARRGGBB
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
public String getRole()Returns the semantic role name (
label, secondaryLabel, background, accent), or null
for explicit ARGB colors.