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 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.
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2025-02-10 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-02-10 UTC."],[],[],null,["# Palette.Swatch\n\nadded in [version 22.1.0](/topic/libraries/support-library/revisions) \nbelongs to Maven artifact com.android.support:palette-v7:28.0.0-alpha1 \nSummary: [Ctors](#pubctors) \\| [Methods](#pubmethods) \\| [Inherited Methods](#inhmethods) \\| [\\[Expand All\\]](#) \n\nPalette.Swatch\n==============\n\n| This package is part of the Android [support library](/topic/libraries/support-library) which is no longer maintained. The support library has been superseded by [AndroidX](/jetpack/androidx) which is part of [Jetpack](/jetpack). We recommend using the AndroidX libraries in all new projects. You should also consider [migrating](/jetpack/androidx/migrate) existing projects to AndroidX. To find the AndroidX class that maps to this deprecated class, see the AndroidX support library [class\n| mappings](/jetpack/androidx/migrate/class-mappings).\n\n\n`\npublic\nstatic\nfinal\n\nclass\nPalette.Swatch\n`\n\n\n`\n\nextends Object\n\n\n`\n\n`\n\n\n`\n\n|---|--------------------------------------------|\n| java.lang.Object ||\n| ↳ | android.support.v7.graphics.Palette.Swatch |\n\n\u003cbr /\u003e\n\n*** ** * ** ***\n\nRepresents a color swatch generated from an image's palette. The RGB color can be retrieved\nby calling [getRgb()](/reference/android/support/v7/graphics/Palette.Swatch#getRgb()).\n\nSummary\n-------\n\n| ### Public constructors ||\n|-----------------------------------------------------------------------------------------------------------------------------------|---|\n| ` `[Palette.Swatch](/reference/android/support/v7/graphics/Palette.Swatch#Palette.Swatch(int, int))`(int color, int population) ` |\n\n| ### Public methods ||\n|------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| ` boolean` | ` `[equals](/reference/android/support/v7/graphics/Palette.Swatch#equals(java.lang.Object))`(Object o) ` |\n| ` int` | ` `[getBodyTextColor](/reference/android/support/v7/graphics/Palette.Swatch#getBodyTextColor())`() ` Returns an appropriate color to use for any 'body' text which is displayed over this [Palette.Swatch](/reference/android/support/v7/graphics/Palette.Swatch)'s color. |\n| ` float[]` | ` `[getHsl](/reference/android/support/v7/graphics/Palette.Swatch#getHsl())`() ` Return this swatch's HSL values. |\n| ` int` | ` `[getPopulation](/reference/android/support/v7/graphics/Palette.Swatch#getPopulation())`() ` |\n| ` int` | ` `[getRgb](/reference/android/support/v7/graphics/Palette.Swatch#getRgb())`() ` |\n| ` int` | ` `[getTitleTextColor](/reference/android/support/v7/graphics/Palette.Swatch#getTitleTextColor())`() ` Returns an appropriate color to use for any 'title' text which is displayed over this [Palette.Swatch](/reference/android/support/v7/graphics/Palette.Swatch)'s color. |\n| ` int` | ` `[hashCode](/reference/android/support/v7/graphics/Palette.Swatch#hashCode())`() ` |\n| ` String` | ` `[toString](/reference/android/support/v7/graphics/Palette.Swatch#toString())`() ` |\n\n| ### Inherited methods |\n|-----------------------|---|\n| From class ` java.lang.Object ` |-------------------|-------------------------------| | ` Object` | ` clone() ` | | ` boolean` | ` equals(Object arg0) ` | | ` void` | ` finalize() ` | | ` final Class\u003c?\u003e` | ` getClass() ` | | ` int` | ` hashCode() ` | | ` final void` | ` notify() ` | | ` final void` | ` notifyAll() ` | | ` String` | ` toString() ` | | ` final void` | ` wait(long arg0, int arg1) ` | | ` final void` | ` wait(long arg0) ` | | ` final void` | ` wait() ` | ||\n\nPublic constructors\n-------------------\n\n### Palette.Swatch\n\nadded in [version 22.1.0](/topic/libraries/support-library/revisions) \n\n```\nPalette.Swatch (int color, \n int population)\n```\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Parameters ||\n|--------------|--------------|\n| `color` | `int` \u003cbr /\u003e |\n| `population` | `int` \u003cbr /\u003e |\n\nPublic methods\n--------------\n\n### equals\n\n```\nboolean equals (Object o)\n```\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Parameters ||\n|-----|-----------------|\n| `o` | `Object` \u003cbr /\u003e |\n\n| Returns ||\n|-----------|--------|\n| `boolean` | \u003cbr /\u003e |\n\n### getBodyTextColor\n\nadded in [version 22.1.0](/topic/libraries/support-library/revisions) \n\n```\nint getBodyTextColor ()\n```\n\nReturns an appropriate color to use for any 'body' text which is displayed over this\n[Palette.Swatch](/reference/android/support/v7/graphics/Palette.Swatch)'s color. This color is guaranteed to have sufficient contrast.\n\n\u003cbr /\u003e\n\n| Returns ||\n|-------|--------|\n| `int` | \u003cbr /\u003e |\n\n### getHsl\n\nadded in [version 22.1.0](/topic/libraries/support-library/revisions) \n\n```\nfloat[] getHsl ()\n```\n\nReturn this swatch's HSL values.\nhsv\\[0\\] is Hue \\[0 .. 360)\nhsv\\[1\\] is Saturation \\[0...1\\]\nhsv\\[2\\] is Lightness \\[0...1\\]\n\n\u003cbr /\u003e\n\n| Returns ||\n|-----------|--------|\n| `float[]` | \u003cbr /\u003e |\n\n### getPopulation\n\nadded in [version 22.1.0](/topic/libraries/support-library/revisions) \n\n```\nint getPopulation ()\n```\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Returns ||\n|-------|--------------------------------------------------------|\n| `int` | the number of pixels represented by this swatch \u003cbr /\u003e |\n\n### getRgb\n\nadded in [version 22.1.0](/topic/libraries/support-library/revisions) \n\n```\nint getRgb ()\n```\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Returns ||\n|-------|--------------------------------------|\n| `int` | this swatch's RGB color value \u003cbr /\u003e |\n\n### getTitleTextColor\n\nadded in [version 22.1.0](/topic/libraries/support-library/revisions) \n\n```\nint getTitleTextColor ()\n```\n\nReturns an appropriate color to use for any 'title' text which is displayed over this\n[Palette.Swatch](/reference/android/support/v7/graphics/Palette.Swatch)'s color. This color is guaranteed to have sufficient contrast.\n\n\u003cbr /\u003e\n\n| Returns ||\n|-------|--------|\n| `int` | \u003cbr /\u003e |\n\n### hashCode\n\n```\nint hashCode ()\n```\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Returns ||\n|-------|--------|\n| `int` | \u003cbr /\u003e |\n\n### toString\n\n```\nString toString ()\n```\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Returns ||\n|----------|--------|\n| `String` | \u003cbr /\u003e |\n\n-\n\n Interfaces\n ----------\n\n - [Palette.Filter](/reference/android/support/v7/graphics/Palette.Filter)\n - [Palette.PaletteAsyncListener](/reference/android/support/v7/graphics/Palette.PaletteAsyncListener)\n-\n\n Classes\n -------\n\n - [Palette](/reference/android/support/v7/graphics/Palette)\n - [Palette.Builder](/reference/android/support/v7/graphics/Palette.Builder)\n - [Palette.Swatch](/reference/android/support/v7/graphics/Palette.Swatch)\n - [Target](/reference/android/support/v7/graphics/Target)\n - [Target.Builder](/reference/android/support/v7/graphics/Target.Builder)"]]