Skip to content

Most visited

Recently visited

navigation
added in version 22.1.0
belongs to Maven artifact com.android.support:palette-v7:27.0.0

Palette.Swatch

public static final class Palette.Swatch
extends Object

java.lang.Object
   ↳ android.support.v7.graphics.Palette.Swatch


Represents a color swatch generated from an image's palette. The RGB color can be retrieved by calling getRgb().

Summary

Public constructors

Palette.Swatch(int color, int population)

Public methods

boolean equals(Object o)
int getBodyTextColor()

Returns an appropriate color to use for any 'body' text which is displayed over this Palette.Swatch's color.

float[] getHsl()

Return this swatch's HSL values.

int getPopulation()
int getRgb()
int getTitleTextColor()

Returns an appropriate color to use for any 'title' text which is displayed over this Palette.Swatch's color.

int hashCode()
String toString()

Inherited methods

From class java.lang.Object

Public constructors

Palette.Swatch

added in version 22.1.0
Palette.Swatch (int color, 
                int population)

Parameters
color int

population int

Public methods

equals

boolean equals (Object o)

Parameters
o Object

Returns
boolean

getBodyTextColor

added in version 22.1.0
int getBodyTextColor ()

Returns an appropriate color to use for any 'body' text which is displayed over this Palette.Swatch's color. This color is guaranteed to have sufficient contrast.

Returns
int

getHsl

added in version 22.1.0
float[] getHsl ()

Return this swatch's HSL values. hsv[0] is Hue [0 .. 360) hsv[1] is Saturation [0...1] hsv[2] is Lightness [0...1]

Returns
float[]

getPopulation

added in version 22.1.0
int getPopulation ()

Returns
int the number of pixels represented by this swatch

getRgb

added in version 22.1.0
int getRgb ()

Returns
int this swatch's RGB color value

getTitleTextColor

added in version 22.1.0
int getTitleTextColor ()

Returns an appropriate color to use for any 'title' text which is displayed over this Palette.Swatch's color. This color is guaranteed to have sufficient contrast.

Returns
int

hashCode

int hashCode ()

Returns
int

toString

String toString ()

Returns
String

This site uses cookies to store your preferences for site-specific language and display options.

Get the latest Android developer news and tips that will help you find success on Google Play.

* Required Fields

Hooray!

Follow Google Developers on WeChat

Browse this site in ?

You requested a page in , but your language preference for this site is .

Would you like to change your language preference and browse this site in ? If you want to change your language preference later, use the language menu at the bottom of each page.

This class requires API level or higher

This doc is hidden because your selected API level for the documentation is . You can change the documentation API level with the selector above the left navigation.

For more information about specifying the API level your app requires, read Supporting Different Platform Versions.

Take a short survey?
Help us improve the Android developer experience.
(Sep 2017 survey)