2017-02-10 322 views
0

我試圖使用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後,但不起作用。

回答

1

你的輸入是半透明的顏色,你期望輸出稍微亮一些。這可以通過將輸入疊加在白色上來實現。

支持-V4庫包含ColorUtils.compositeColors這確實你需要:

final int input = Color.argb(204, 40, 40, 40); 
final int output = ColorUtils.compositeColors(input, Color.WHITE); 
+0

哇,工作完美!謝謝! :d – cnavarreteliz