-1

enter image description here

I am searching for from last 2 days to implement color palette like this image. I want exatract the colors from the image. Please help me.

Thanks in advance.

Manikanta Ottiprolu
  • 751
  • 1
  • 7
  • 23
  • have u seen this https://developer.android.com/reference/android/support/v7/graphics/Palette.html ?? – Budius Feb 04 '15 at 12:46
  • Yes, but i am getting "cannot resolve symbol 'Palette'". I am using android studio. – Manikanta Ottiprolu Feb 04 '15 at 12:52
  • than the issue is that you did not proper imported the support libraries, are you using Android Studio or Eclipse/ADT ? check this link https://developer.android.com/tools/support-library/setup.html – Budius Feb 04 '15 at 12:54

1 Answers1

2

from the docs: https://developer.android.com/reference/android/support/v7/graphics/Palette.html

make sure your application have the support libraries

import android.support.v7.graphics.Palette <<< VERY IMPORTANT

and just run the pallete code as per example

Palette.generateAsync(bitmap, new Palette.PaletteAsyncListener() {
     public void onGenerated(Palette palette) {
          Palette.Swatch swatch = palette.getDarkVibrantSwatch();
          int backgroundColor = swatch.getRgb();
          int titleColor = swatch.getTitleTextColor();
          int textColor = swatch.getBodyTextColor();
     }
 });

edit:

as pointed by @CommonsWare, this is how to setup build.gradle to import the library.

// inside your dependencies object
dependencies {
    compile 'com.android.support:palette-v7:21.0.3'
    // all your other dependencies
}
CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491
Budius
  • 39,391
  • 16
  • 102
  • 144
  • 2
    You will also need to add the `palette-v7` dependency, by having a `compile 'com.android.support:palette-v7:21.0.3'` line in the `dependencies` closure of your `build.gradle` file in the `app/` module (assuming a typical Android Studio project setup). – CommonsWare Feb 04 '15 at 12:54
  • thanks @CommonsWare that's what I meant by "have the support libraries", but your explanation is certanly more technical. If you don't mind I'll add to the answer. – Budius Feb 04 '15 at 12:55
  • 1
    Go right ahead! There are so many support libraries nowadays that, for Android Studio users, I just like to provide more specific instructions, since they're short. – CommonsWare Feb 04 '15 at 12:57