可绘制Android的颜色 [英] Invert colors of drawable Android
本文介绍了可绘制Android的颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
是否可以在Drawable中反转颜色?你知道吗?
Is it possible to "invert" colors in a Drawable? Kind of what you have in a negative, you know?
我知道可以将Drawable更改为黑白...如何反转颜色?
I know it's possible to change a Drawable to black and white... what about inverting colors?
谢谢!
推荐答案
经过一番研究,
这里是:
/**
* Color matrix that flips the components (<code>-1.0f * c + 255 = 255 - c</code>)
* and keeps the alpha intact.
*/
private static final float[] NEGATIVE = {
-1.0f, 0, 0, 0, 255, // red
0, -1.0f, 0, 0, 255, // green
0, 0, -1.0f, 0, 255, // blue
0, 0, 0, 1.0f, 0 // alpha
};
drawable.setColorFilter(new ColorMatrixColorFilter(NEGATIVE));
这篇关于可绘制Android的颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文