转载自:http://blog.youkuaiyun.com/hpu_zyh/article/details/43117177
效果:

Google提供的用来提取图像主要颜色的类,Palette从图像中提取突出的颜色,这样可以把色值赋给ActionBar、或者其他,可以让界面整个色调统一。
这个类能提取以下突出的颜色:
Vibrant(充满活力的) Vibrant dark(充满活力的黑) Vibrant light(充满活力的亮)
Muted(柔和的) Muted dark(柔和的黑) Muted lighr(柔和的亮)
Palette提供的方法:
Pallet.Swatch 类是包含颜色的载体,通过以下方法获取
- palette.getVibrantSwatch();
- palette.getMutedSwatch();
- palette.getLightVibrantSwatch();
- palette.getLightMutedSwatch();
- palette.getDarkVibrantSwatch();
- palette.getDarkMutedSwatch()
Swatch包含的方法:
- getPopulation(): the amount of pixels which this swatch represents.
- getRgb(): the RGB value of this color.
- getHsl(): the HSL value of this color.
- getBodyTextColor(): the RGB value of a text color which can be displayed on top of this color.
- getTitleTextColor(): the RGB value of a text color which can be displayed on top of this color.