Search code examples
androidandroid-palette

How to import Palette.Builder android - AppCompat, Eclipse


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?


Solution

  • 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)));
    
                         }
    });