当我尝试使用 RGB 值创建颜色时,我收到一条消息说“Color() in Color cannot be applied to:”,然后它说“Expected parameter:”和“Actual Arguments:”import android.graphics.Color;Color myColor = new Color (0,0,0); 当我尝试运行该程序时,它说:error: constructor Color in class Color cannot be applied to given types;required: no argumentsfound: int,int,intreason: actual and formal argument lists differ in length
1 回答
幕布斯7119047
TA贡献1794条经验 获得超8个赞
我要说的是
//Color blackColor my Color = Color.valueOf(0.0f,0.0f,0.0f);
请记住,值在 [0,1] 范围内,而不是 [0,255]
或者,正如@DaveNewton 所建议的,我们可以使用以下任一方法:
//Color white Color myColor = Color.valueOf(Color.rgb(1.0f,1.0f,1.0f));//floats, [0,1] Color myColor = Color.valueOf(Color.rgb(255,255,255));//ints, [0,255]
添加回答
举报
0/150
提交
取消