Class DynamicColors
java.lang.Object
com.codename1.ui.plaf.DynamicColors
The system's dynamic color palette: Material You on Android 12 and newer, the accent color on platforms that have one. On every other platform the methods answer null or the fallback, so an application can keep its own brand colors there.
The palette is a list of RGB values without alpha, indexed by the constants of this class.
int accent = DynamicColors.getColor(DynamicColors.ACCENT, 0x3f51b5);
Label title = new Label("Hello");
title.getAllStyles().setFgColor(accent);
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intThe primary accent color.static final intA light tone of the accent, for containers.static final intThe number of palette entries.static final intA dark neutral, for dark mode backgrounds.static final intA light neutral, for backgrounds.static final intA dark tone of the accent, for text onACCENT_CONTAINER.static final intThe secondary accent color.static final intThe tertiary accent color. -
Method Summary
Modifier and TypeMethodDescriptionstatic intgetColor(int index, int fallback) One palette entry, or the fallback when the platform has no palette.static int[]The palette, indexed by the constants of this class, or null when the platform has none.static booleanTrue when the platform supplies a dynamic palette.static voidsetImplementation(com.codename1.impl.CodenameOneImplementation impl) Invoked internally from Display, this method is for internal use only
-
Field Details
-
ACCENT
public static final int ACCENTThe primary accent color.- See Also:
-
ACCENT_CONTAINER
public static final int ACCENT_CONTAINERA light tone of the accent, for containers.- See Also:
-
ON_ACCENT_CONTAINER
public static final int ON_ACCENT_CONTAINERA dark tone of the accent, for text onACCENT_CONTAINER.- See Also:
-
SECONDARY
public static final int SECONDARYThe secondary accent color.- See Also:
-
TERTIARY
public static final int TERTIARYThe tertiary accent color.- See Also:
-
NEUTRAL_LIGHT
public static final int NEUTRAL_LIGHTA light neutral, for backgrounds.- See Also:
-
NEUTRAL_DARK
public static final int NEUTRAL_DARKA dark neutral, for dark mode backgrounds.- See Also:
-
COUNT
public static final int COUNTThe number of palette entries.- See Also:
-
-
Method Details
-
setImplementation
public static void setImplementation(com.codename1.impl.CodenameOneImplementation impl) Invoked internally from Display, this method is for internal use only
Parameters
impl: implementation instance
-
isSupported
public static boolean isSupported()True when the platform supplies a dynamic palette.
Returns
true when
#getPalette()answers non-null -
getPalette
public static int[] getPalette()The palette, indexed by the constants of this class, or null when the platform has none. Entries a platform lacks repeat the accent.
Returns
a new array of
COUNTRGB values, or null -
getColor
public static int getColor(int index, int fallback) One palette entry, or the fallback when the platform has no palette.
Parameters
index: one of the constants of this classfallback: the RGB value to answer without a palette
Returns
the RGB value
-