在build.gradle添加依赖
compile 'com.github.florent37:glidepalette:1.0.6'
使用
TextView tvColor=(TextView) findViewById(R.id.testte); ImageView imageView = (ImageView)findViewById(R.id.testimage); tvColor.setText(style); ImageManager.loadAndPalette(MainActivity.this, "http://f.hiphotos.baidu.com/image/pic/item/503d269759ee3d6db032f61b48166d224e4ade6e.jpg", imageView, tvColor);主方法
/* 加载指定URL的图片并设置到targetView, 取主色调palete */ public static void loadAndPalette(Context context, String url, ImageView targetView, TextView textView) { Glide.with(context).load(url) .diskCacheStrategy(DiskCacheStrategy.SOURCE) .listener(GlidePalette.with(url) .use(GlidePalette.Profile.VIBRANT) .intoBackground(textView, GlidePalette.Swatch.RGB) .intoTextColor(textView, GlidePalette.Swatch.BODY_TEXT_COLOR) .crossfade(true) ) .into(targetView); }