Client API. The Codename One framework your app is built on: this runs on the device, not in a backend.
public final class DynamicColors
- Object
- 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);Fields
public static final int ACCENT = 0 | The primary accent color. |
public static final int ACCENT_CONTAINER = 1 | A light tone of the accent, for containers. |
public static final int ON_ACCENT_CONTAINER = 2 | A dark tone of the accent, for text on ACCENT_CONTAINER. |
public static final int SECONDARY = 3 | The secondary accent color. |
public static final int TERTIARY = 4 | The tertiary accent color. |
public static final int NEUTRAL_LIGHT = 5 | A light neutral, for backgrounds. |
public static final int NEUTRAL_DARK = 6 | A dark neutral, for dark mode backgrounds. |
public static final int COUNT = 7 | The number of palette entries. |
Methods
public static void setImplementation(CodenameOneImplementation impl) | Invoked internally from Display, this method is for internal use only |
public static boolean isSupported() | True when the platform supplies a dynamic palette. |
public static int[] getPalette() | The palette, indexed by the constants of this class, or null when the platform has none. |
public static int getColor(int index, int fallback) | One palette entry, or the fallback when the platform has no palette. |
Inherited methods
Field details
ACCENT
public static final int ACCENT = 0The primary accent color.
ACCENT_CONTAINER
public static final int ACCENT_CONTAINER = 1A light tone of the accent, for containers.
ON_ACCENT_CONTAINER
public static final int ON_ACCENT_CONTAINER = 2A dark tone of the accent, for text on
ACCENT_CONTAINER.SECONDARY
public static final int SECONDARY = 3The secondary accent color.
TERTIARY
public static final int TERTIARY = 4The tertiary accent color.
NEUTRAL_LIGHT
public static final int NEUTRAL_LIGHT = 5A light neutral, for backgrounds.
NEUTRAL_DARK
public static final int NEUTRAL_DARK = 6A dark neutral, for dark mode backgrounds.
COUNT
public static final int COUNT = 7The number of palette entries.
Method details
setImplementation
public static void setImplementation(CodenameOneImplementation impl)Invoked internally from Display, this method is for internal use only
Parameters
implCodenameOneImplementation- implementation instance
isSupported
public static boolean isSupported()True when the platform supplies a dynamic palette.
Returns
true when
#getPalette() answers non-nullgetPalette
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
COUNT RGB values, or nullgetColor
public static int getColor(int index, int fallback)One palette entry, or the fallback when the platform has no palette.
Parameters
indexint- one of the constants of this class
fallbackint- the RGB value to answer without a palette
Returns
the RGB value