Android画布油漆无法设置深色

时间:2012-05-16 13:05:55

标签: android

我正在进行绘画应用,我将布局背景设置为白色,并将绘画颜色设置为黑色。但是,在画布上我得到透明的黑色,我希望它是帆布颜料的深色。

我的输出在屏幕截图下方:

enter image description here

我的代码如下:

public DrawView(Context context){
    super(context);
    setFocusable(true);
    setFocusableInTouchMode(true);      
    this.setOnTouchListener(this);
    mPaint = new Paint();
    mPaint.setAntiAlias(true);
    mPaint.setDither(true);
    mPaint.setColor(0x80808080);
    mPaint.setStyle(Paint.Style.STROKE);
    mPaint.setStrokeJoin(Paint.Join.ROUND);
    mPaint.setStrokeCap(Paint.Cap.ROUND);
    mPaint.setStrokeWidth(6);
    mCanvas = new Canvas();
    mPath = new Path();
    paths.add(mPath);
}    

2 个答案:

答案 0 :(得分:3)

mPaint.setColor(Color.BLACK);

而不是

mPaint.setColor(0x80808080);

答案 1 :(得分:2)

您的Paint的Alpha通道设置为略透明。插入此行。

mPaint.setAlpha(255);