颜色提取器------Palette

本文介绍Google提供的Palette类,用于从图像中提取主要颜色,并应用于UI设计中保持界面色调一致。支持提取充满活力(Vibrant)及柔和(Muted)等不同风格的颜色。

转载自: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 类是包含颜色的载体,通过以下方法获取

[java]  view plain copy print ? 在CODE上查看代码片 派生到我的代码片
  1. palette.getVibrantSwatch();  
  2. palette.getMutedSwatch();  
  3. palette.getLightVibrantSwatch();  
  4. palette.getLightMutedSwatch();  
  5. palette.getDarkVibrantSwatch();  
  6. palette.getDarkMutedSwatch()  

Swatch包含的方法:

[java]  view plain copy print ? 在CODE上查看代码片 派生到我的代码片
  1. getPopulation(): the amount of pixels which this swatch represents.  
  2. getRgb(): the RGB value of this color.  
  3. getHsl(): the HSL value of this color.  
  4. getBodyTextColor(): the RGB value of a text color which can be displayed on top of this color.  
  5. getTitleTextColor(): the RGB value of a text color which can be displayed on top of this color.  
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值