首页 > 其他分享 >Android(Lollipop/5.0) Material Design(五) 使用图片

Android(Lollipop/5.0) Material Design(五) 使用图片

时间:2022-12-19 22:35:47浏览次数:42  
标签:5.0 Palette tint int Material defaultColor Design android 图片



官网地址:https://developer.android.com/intl/zh-tw/training/material/drawables.html#DrawableTint

以下图片的功能能帮助你在app中实现Material设计:



·图片着色

·颜色提取

·矢量图片

Tint Drawable Resources  为图片资源染色


在Android 5.0(API级别21)及以上,你可以将图片和9-patch定义为掩饰透明度。你能使用颜色资源(如,?android:attr/colorPrimary)或主题属性来给它们上色。通常,你只需创建这些资源一次,且自动匹配你的主题为它们上色。


可以为BitmapDrawable和NinePatchDrawable 的对象使用setTint(int tint)进行染色。也可以在xml中定义android:tint和android:tintMode属性。

·关于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>



·关于xml中定义属性,如:

<?xmlversion="1.0"encoding="utf-8"?>

<nine-patchxmlns:android="http://schemas.android.com/apk/res/android" 

    android:tint="@color/abc_primary_text_material_light" 

    android:tintMode="src_over"

    ... >

</nine-patch>

Extract Prominent Colors from an Image  从图片抽取明显的颜色


在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()。

Create Vector Drawables  创建矢量图片

在Android 5.0(API级别21)及以上 可以创建矢量图片,如下面的例子可以绘制一个心形的矢量图:



Android(Lollipop/5.0) Material Design(五) 使用图片_android




矢量图片在Android中使用VectorDrawble对象与之对应。path的更多信息请见:http://www.w3.org/TR/SVG11/paths.html#PathData。

标签:5.0,Palette,tint,int,Material,defaultColor,Design,android,图片
From: https://blog.51cto.com/u_11407799/5953918

相关文章

  • OCaml 5.0.0 正式发布
    OCaml5.0.0正式发布来源:OSCHINA编辑: 局2022-12-1808:02:45 0OCaml是一个函数式、指令式、模块化、面向对象的通用的编程语言,源自ML(MetaLangua......
  • hualinux 进阶 vue 5.0:vue UI组件介绍及Element UI
    目录​​ 一、vue流行的UI介绍​​​​1.1un-app所有前端框架​​​​1.2pc浏览器​​​​1.3 小程序mpvue​​​​1.4移动端​​​​1.5 桌面端(客户端)Electron ​​......
  • HLS学习笔记——vivado HLS的Design Flow概念
    本博客为​​跟XilinxSAE学HLS系列视频讲座-高亚军​​的学习笔记。软件工程师怎么了解FPGA架构VivadoHLS是将基于C/C++描述的算法转化成相应的RTL代码,最终在FPGA上实现......
  • Zabbix5.0微信报警
    3.1、注测企业微信:3.2、企业微信注册成功后进入后台管理:3.3、添加一个部门,并记住部门id:#我这里添加的子部门ID为23.4、添加一个用户到上面创建的部门里面(这里采取直接将管......
  • zabbix 5.0 页面出现中文乱码解决方法
    问题:zabbix切换为中文后,监控页面中的maxminavg均以方块显示,无法显示中文解决办法:在windows系统对应的目录找到字体文件,上传到zabbix-server对应的字体目录。修改配置文......
  • PowerDesigner中 用name列替换comment列作为字段描述
    打开Tools--ExecuteCommands--RunScript,运行以下脚本:OptionExplicitValidationMode=TrueInteractiveMode=im_BatchDimmdl'thecurrentmodel'getthecurrent......
  • DDD Domain-Driven Design
    商品中心答疑​​http://www.nmalls.com/public/help.htm​​阿里高级技术专家方法论:如何写复杂业务代码?​​https://mp.weixin.qq.com/s/pdjlf9I73sXDr30t-5KewA​​以商品......
  • 数据库设计工具PowerDesigner
    PowerDesigner是一款非常全面的数据库设计工具。使用PowerDesigner可以快速创建表,支持表与表之间建立关系,界面简洁,功能强大。同时支持将sql脚本导出,多种导出类型任意挑选,简......
  • centos7 redis5.0以后版本 集群部署示例
    简言1.redis5.0版本以前的集群部署是使用ruby脚本完成的,略为复杂2.本篇博客讲解redis5.0版本以后的集群部署,由于集成到了create_cluster中(位置:redis根目录/utils/create-c......
  • ubuntu16 redis5.0以后版本集群部署示例
    简言1.redis5.0版本以前的集群部署是使用ruby脚本完成的,略为复杂,具体示例见笔者的这篇博客,​​ubuntu16redis5.0以前版本集群部署示例_YZF_Kevin的博客2.本篇博客讲解red......