如何导入 Palette.Builder android - AppCompat, Eclipse

How to import Palette.Builder android - AppCompat, Eclipse

我有以下 Palette 代码,它获取 DarkMutedColor 并设置为我的 textView 的背景。

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

            public void onGenerated(Palette palette) {

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

            }

        });

但是,我最近遇到了 Palette.Builder 并想知道如何使用它。

来自文档 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

但是,当我键入 Palette(点)时,我找不到任何 class 命名的 Builder?我如何导入 Palette.Builder 及其方法?

解决方案是,更新您的 SDK 并更新主项目的 libs 文件夹中以前使用的 .jar 文件。

并使用它:

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

                    @Override
                    public void onGenerated(Palette palette) {

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

                     }
});