Nurul Endah Amelia Nurul Endah Amelia - 6 months ago 13
Android Question

Android setColor - want to change color but always didn't work

I want to change color to used in the following example to brown, but my attempts are not working:

mPaint = new Paint();
mPaint.setAntiAlias(true);
mPaint.setDither(true);
mPaint.setColor(Color.RED);


This doesn't work:

mPaint.setColor(Color.Brown);


nor does this:

mPaint.setColor(mPaint.setColor(0x00994C00));


It only works when I change the color to to
RED
,
GREEN
,
BLUE
,
CYAN
,
MAGENTA
.

Can someone help me to solve this problem?

Answer

Try:

mPaint.setColor(Color.argb(0xff, 0x99, 0x4c, 0x00));

or:

mPaint.setColor(0xff994c00);