0

I have the following code for Palette, which gets the DarkMutedColor and sets to the background of my textView.

    Palette.generateAsync(response.getBitmap(),
        new Palette.PaletteAsyncListener() {

            public void onGenerated(Palette palette) {

                holder.title.setBackgroundColor(
                        palette.getDarkMutedColor(
                                Color.parseColor(Const.ACTIONBAR_BACKGROUND)));

            }

        });

But, i recently came across Palette.Builder and wondering how to use it.

From Documentation here and here:

Instances are created with a Palette.Builder which supports several options to tweak the generated Palette. See that class' documentation for more information.

Generation should always be completed on a background thread, ideally the one in which you load your image on. Palette.Builder supports both synchronous and asynchronous generation

But, i cant find any class named Builder, when i type, Palette(dot)? How do i import, Palette.Builder and its methods?

Vamsi Challa
  • 11,038
  • 31
  • 99
  • 149
  • Have you tried writing `android.support.v7.graphics.Palette.Builder`? – Sufian Apr 27 '15 at 13:54
  • I tried, but it says, android....Builder cannot be resolved. – Vamsi Challa Apr 27 '15 at 13:54
  • 1
    If using Android Studio, please update your question with your gradle file. If using Eclipse, please check if AppCompat is added as library. – Sufian Apr 27 '15 at 14:01
  • My targetSDKVersion is 21. I am using Eclipse. So, in order to use it, should my minSDKVersion be 21? Can you please point me to the source, where it says, its only available for API >=21. – Vamsi Challa Apr 27 '15 at 14:04
  • 1
    It's not for API >= 21. Can you check first to make sure you have at least 22.1 version of the Android Support Library, and that your project is indeed referring to that version? – Kai Apr 27 '15 at 14:14
  • Yeah.. I updated my SDK, but i didn't update the .jar file in my project. That was the problem. thanks.. – Vamsi Challa Apr 27 '15 at 15:48

1 Answers1

0

The solution was, update your SDK and update the previously used .jar file in your libs folder of the Main project.

And to use it:

    Palette.from(response.getBitmap()).generate(new PaletteAsyncListener() {

                    @Override
                    public void onGenerated(Palette palette) {

                        holder.title.setBackgroundColor(palette.getDarkMutedColor(Color
                                    .parseColor(Const.ACTIONBAR_BACKGROUND)));

                     }
});
Vamsi Challa
  • 11,038
  • 31
  • 99
  • 149