使用android:tint属性去调整色调。
android:tintMode 着色模式
screen
multiply
and
src_atop/src_in/src_over
setTint(int tint)
setTint(int tint)的参数,可以是一个@color/下的属性,也可以是一个xml的selector,selector中的item是使用了数字的

<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_focused="true" android:color="@color/testcolor1"/>
<item android:state_pressed="true" android:state_enabled="false" android:color="@color/testcolor2" />
<item android:state_enabled="false" android:color="@color/testcolor3" />
<item android:color="@color/testcolor5"/>
</selector>

setColorFilter 同时设置着色颜色和着色模式

从图片中抽取颜色:
在api21上的support-v7库中有一个android-support-v7-palette.jar,它能够让你从图片中抽取一些显眼的颜色:
Palette p = Palette.generate(Bitmap bitmap);
·鲜艳的 p.getVibrantColor(int defaultColor);
·鲜艳的黑暗 p.getDarkVibrantColor(int defaultColor);
·鲜艳的明亮 p.getLightVibrantColor(int defaultColor);
·柔和的 p.getMutedColor(int defaultColor);
·柔和的黑暗 p.getDarkMutedColor(int defaultColor);
·柔和的明亮 p.getLightMutedColor(int defaultColor);
Palette.generate(),用于在后台线程中执行,如果在前台线程中创建Palette对象,那么可以使用Palette.generateAsync()。

android 5.0新特性学习--Drawable Tinting(为图片资源着色)的更多相关文章

  1. android 5.0新特性学习--视图阴影

    android 5.0的视图阴影主要是体验出层次性,就是在一个物体上面叠加上一层的设计,而这种设计就是除了传统的,x,y的纸面层,还有就是透过纸面的z轴的层次设计. elevation: 高度,静态属 ...

  2. android 5.0新特性学习总结之下拉刷新(一)

    android 5.0 后google最终在 support v4 包下 添加了下拉刷新的控件 项目地址: https://github.com/stormzhang/SwipeRefreshLayo ...

  3. android 5.0新特性学习--RecyclerView

    在过去很多年,我们的PC或者手机设备都是采用拟物化的设计风格,IOS采用扁平化的特性,android在2014年IO大会上说采用Material Design的设计风格,显示效果不能过于生硬的转换,而 ...

  4. android 5.0新特性学习--视图轮廓

    ViewOutlineProvider -- 视图轮廓setOutlineProvider--可以使用View.setClipToOutline方法去剪切一个视图的outline区域.只有rectan ...

  5. android 5.0新特性学习--CardView

    CardView继承自FrameLayout类,可以在一个卡片布局中一致性的显示内容,卡片可以包含圆角和阴影.CardView是一个Layout,可以布局其他View. 官网地址:https://de ...

  6. Android 6.0 新特性 整理 资料来自网络

    Android 6.0新特性 Runtime Permissions Doze and App Standby Apache HTTP Client Removal BoringSSL Access ...

  7. Android 8.0 新特性

    Android 8.0 (Android Oreo(奥利奥))新特性介绍 通知渠道 - Notification Channels 通知渠道是由应用自行定义的通知内容类别,借助渠道,开发者可以让用户对 ...

  8. android 7.0 新特性 和对开发者的影响

    android 7.0新特性 - jiabailong的专栏 - 博客频道 - CSDN.NEThttp://blog.csdn.net/jiabailong/article/details/5241 ...

  9. 腾讯云安全:开发者必看|Android 8.0 新特性及开发指南

    欢迎大家关注腾讯云技术社区-博客园官方主页,我们将持续在博客园为大家推荐技术精品文章哦~ 背景介绍 谷歌2017 I/O开发者大会今年将于5月17-19日在美国加州举办.大会将跟往年一样发布最新的 A ...

随机推荐

  1. Openjudge-计算概论(A)-苹果和虫子

    描述 你买了一箱n个苹果,很不幸的是买完时箱子里混进了一条虫子.虫子每x小时能吃掉一个苹果,假设虫子在吃完一个苹果之前不会吃另一个,那么经过y小时你还有多少个完整的苹果? 输入输入仅一行,包括n,x和 ...

  2. android service文章转载

    郑重转载几篇网络文章: Android Service使用 http://www.cnblogs.com/linlf03/archive/2013/06/14/3135273.html Android ...

  3. app/desktop/view/index.html 显示授权标识

    app/desktop/view/index.html 显示授权标识

  4. 带宽 VS CDN (转载)

    并发的影响因素:带宽.web server(含php).static server.数据库 带宽价格: 静态IP企业宽带 5M 10M 50M 100M 200M 盛大云 华东双线 216/月 396 ...

  5. jqgird 实践

    $.jgrid.defaults.styleUI="Bootstrap"; $("#table_list_2").jqGrid({ multiselect: t ...

  6. Android 中OKHttp请求数据get和post

    1:在Android Studio 的 build.gradle下  添加 然后再同步一下 compile 'com.squareup.okhttp:okhttp:2.4.0'compile 'com ...

  7. webstrom官方的活动模版介绍

    编辑模板变量对话框 文件|设置|生活模板--编辑变量Windows和LinuxWebStorm |偏好|生活模板--编辑变量在OS XCtrl + Alt + S 当你点击对话框打开 编辑变量按钮模板 ...

  8. ios简单更改系统TabBar的高度

    - (void)viewDidLayoutSubviews { [super viewDidLayoutSubviews]; CGRect frame = self.tabBar.frame; fra ...

  9. .net core 系列

    1..net core 验证码 2..net core 导出excel 3..net core 上传文件 4..net core 时间戳转换 5..net core 读取配置文件 6..net cor ...

  10. java IO类图