Palette
Palette从图像中提取突出的颜色,这样可以把色值赋给ActionBar、或者其他,可以让界面整个色调统一,效果见上图(Palette)。
Palette这个类中提取以下突出的颜色:
Vibrant (有活力)
Vibrant dark(有活力 暗色)
Vibrant light(有活力 亮色)
Muted (柔和)
Muted dark(柔和 暗色)
Muted light(柔和 亮色)
提取色值代码如下:
Bitmap bm = BitmapFactory.decodeResource(getResources(), item.image);
Palette palette = Palette.generate(bm);
if (palette.getLightVibrantColor() != null) {
name.setBackgroundColor(palette.getLightVibrantColor().getRgb());
getSupportActionBar().setBackgroundDrawable(new ColorDrawable(palette.getLightVibrantColor().getRgb()));
// getSupportActionBar().
}