拒绝在颜色类型中添加参数

时间:2012-08-01 06:43:04

标签: java android animation colors paint

我正在绘画线,我遇到了改变颜色的基本问题:S:S

我有以下代码,我在最后一行代码中遇到错误我无法将参数添加到新颜色(???)>>我无法添加R,G,B颜色编号

        Paint paint = new Paint();
        Random random = new Random();
        int R = (int)(Math.random()*256);
        int G = (int)(Math.random()*256);
        int B= (int)(Math.random()*256);
        paint.setColor(new Color(R , G , B));

1 个答案:

答案 0 :(得分:1)

您无法像这样创建Color个对象。 Color只是一个静态Android助手类,可以处理基于颜色的操作。

试试这个:

paint.setColor(Color.rgb(R , G , B));

供参考,请参阅Color.rgb(...) method