The Palette library, part of Android Support Library (now migrated to AndroidX palette), extracts representative colors from a Bitmap. In Material Design, deriving UI colors from imagery is a common pattern, and Palette makes this straightforward.

Supported Color Profiles
Palette provides six color profiles covering vibrant to muted tones:
| Profile | Description |
|---|---|
| Vibrant | Bright, saturated |
| Vibrant Dark | Dark variant of vibrant |
| Vibrant Light | Light variant of vibrant |
| Muted | Subdued, desaturated |
| Muted Dark | Dark variant of muted |
| Muted Light | Light variant of muted |
Each profile corresponds to a Palette.Swatch object that provides RGB/HSL values, population count, and recommended text colors for overlaying on the swatch.
Basic Usage
Palette supports both synchronous and asynchronous generation:
| |
The synchronous generate method completes in tens of milliseconds. The async variant runs on a background thread via AsyncTask and delivers results through a callback.
About the numColors Parameter
numColors controls the number of colors extracted:
For landscapes, 12-16 colors suffice. For images dominated by faces, increase to 24-32 for better detail.
Smaller values yield faster generation; larger values produce finer color granularity. Default is 16.
Example
The following example extracts colors from a Bitmap and applies them to the ActionBar and a set of views:
| |
Each getXxxColor() method accepts a default color parameter, used when the requested profile is not present in the image.
Migration to AndroidX
The original v7 Palette library has migrated to AndroidX:
| |
The API remains largely the same. The Builder pattern (Palette.from(bitmap).generate()) is recommended for new code, offering customization options like maximumColorCount(), addFilter(), and resizeBitmapArea().