是否可以在Android中从xml更改材质设计图标颜色? [英] Is it possible to change material design icon color from xml in Android?

查看:735
本文介绍了是否可以在Android中从xml更改材质设计图标颜色?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我实际上是想在我的应用中使用彩色图标。我已经从这里下载了官方资料设计图标包。现在这个包中的所有图标都是白色,灰色或黑色。但我希望图标颜色不同。
类似此图片。电话和邮件图标是蓝色的。我怎样才能做到这一点?

I'm actually trying to use colored icons in my app. I've downloaded the official material design icon pack from here. Now all the icons in this pack are either white, grey or black. But I want the icons to be of a different color. Something like the icons on the left side in this image. The phone phone and mail icons are blue. How can I accomplish this?

推荐答案

如需更改图标颜色,请尝试

For changing icon color try

<ImageButton
    android:layout_width="your value"
    android:layout_height="your value"
    /* and so on ... */

    android:tint="YourColor"
    />

注意:色调的颜色涂在图像的顶部,而不是替换颜色。因此,在黑色图像上的色调#80ff0000 会在背景上为黑色提供50%的红色,而不是50%的红色。即这不等同于iOS模板图像。

Note: the tint color is painted ontop of the image, not a replacement color. So tint #80ff0000 on a black image gives you 50 % red on black, not 50 % red on the background. I.e. this is not equivalent to iOS template images.

这篇关于是否可以在Android中从xml更改材质设计图标颜色?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆