Android - 将ARGB颜色转换为RGB
问题描述:
我试图使用alpha来获取颜色的rgb值,这意味着使用不同的红色,绿色和蓝色值完全不透明。Android - 将ARGB颜色转换为RGB
例如,
Color.argb(204, 40, 40, 40) // I have this color
Color.rgb(48, 48, 48) // I expect this value
我试着转换到ARGB HEX和HEX为rgb后,但不起作用。
答
你的输入是半透明的颜色,你期望输出稍微亮一些。这可以通过将输入叠加在白色上来实现。
支持-V4库包含ColorUtils.compositeColors
这确实你需要:
final int input = Color.argb(204, 40, 40, 40);
final int output = ColorUtils.compositeColors(input, Color.WHITE);
哇,工作完美!谢谢! :d – cnavarreteliz