Android 5.x新特性之-Palette类
来源:互联网 发布:游戏神作 知乎 编辑:程序博客网 时间:2024/06/07 05:02
1、Palette简介
Palette中文翻译:调色板,android系统允许我们动态的获取图片或者控件的颜色,来为布局控件提供颜色,保持统一的外观颜色值。
使用Palette需要到sdk\extras\android\support\v7\palette目录下-->打开libs目录-->android-support-v7-palette.jar包-->copy到你项目的libs目录下-->使用Palette。
2.Palette的简单使用
Palette.generateAsync(bmp, new Palette.PaletteAsyncListener() { @Override public void onGenerated(Palette palette) { Palette.Swatch swatch = palette.getVibrantSwatch(); if(null != swatch) { mTextView.setBackgroundColor(swatch.getRgb()); mTextView.setTextColor(swatch.getTitleTextColor()); } } });
由于在Android设备中,对图像的处理有可能是耗时操作,因此,Palette类通过异步接口onGenerated回调的方法
通过调色板更改了TextViewde字体颜色和背景色
来获得Bitmap的颜色值。Palette类获得的颜色值有以下几种类型:
Palette.Swatch a = palette.getVibrantSwatch();//有活力 Palette.Swatch b = palette.getDarkVibrantSwatch();//有活力 暗色 Palette.Swatch c = palette.getLightVibrantSwatch();//有活力 亮色 Palette.Swatch d = palette.getMutedSwatch();//柔和 Palette.Swatch e = palette.getDarkMutedSwatch();//柔和 暗色 Palette.Swatch f = palette.getLightMutedSwatch();//柔和 亮色 我们从以上颜色中可以获取到如下颜色值: int color1 = a.getBodyTextColor();//内容颜色 int color2 = a.getTitleTextColor();//标题颜色 int color3 = a.getRgb();//rgb颜色本文转载自 http://blog.csdn.net/caihongdao123/article/details/51517323
阅读全文
0 0
- Android 5.x新特性之-Palette类
- Android 5.x新特性之利用Palette获取图片的主题色
- Android 5.X 新特性详解(一)——主题、Palette、阴影、着色和裁剪
- Android Lollipop 新特性 - Palette
- Android Lollipop 新特性 - Palette
- Android Lollipop 新特性 - Palette
- Android Lollipop 新特性 - Palette
- Android Lollipop 新特性 - Palette
- Android 5.x之Toolbar和Palette
- Android 5.x(一) 新控件之RecyclerView,CardView,Palette的使用
- Android 5.X 新特性详解(一)MD主题、Palette、视图阴影、Tinting(着色)和Clipping(裁剪)
- Android Lollipop 新特性 -- Palette RoundedBitmapDrawable
- Android 5.X 新特性
- Android 5.X新特性
- Android 5.X之Ripple,Palette的详解
- Android5.x 新控件之RecyclerView,CardView,Palette的使用
- Android5.x 新控件之RecyclerView,CardView,Palette的使用
- Android5.x 新控件之RecyclerView,CardView,Palette的使用
- 设计模式-概念(策略模式,观察者模式,装饰者模式)
- Android 7.0 LowMemoryKiller 初识
- 子窗口与弹出窗口的坑使用笔记
- 卷积神经网络基础
- 12.2Groovy使用MetaClass拦截方法
- Android 5.x新特性之-Palette类
- sql一对多查询最大值的列出来
- svn中的eclipse项目转为Android studio项目
- Thopos 7 v7.1 1CD(地形测量软件)
- Windows10 安装Ubuntu子系统,解决从应用商店下载慢的问题。
- 浏览器调试出错
- ThinkPHP 事务回滚!
- oracle 表被锁定如何解锁
- SerialPort.DataReceived 事件